1

以下是我的代码。它在本地主机上运行良好。不知何故,当我将其上传到服务器图像时,无法保存。

索引.php:

<!doctype html>
<html lang="en">
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   <title>Simple Capture Web camera image </title>
   <style type="text/css">
      body { font-family: Helvetica, sans-serif; }
      h2, h3 { margin-top:0; }
      form { margin-top: 16px; }
      form > input { margin-right: 16px; }
      #img_output { float:right; margin:21px; padding:21px; border:1px solid; background:#3d3d3d; }
   </style>
</head>
<body>
    
   <div id="img_output">Live captured image will Display here...</div>
   
   <h1>jQuery Capture Web camera image </h1>
   <h3>Live Demo And Example Demonstrates simple Images 600x460 capture & display here</h3>
   
   <div id="live_camera"></div>
   
   
   <script type="text/javascript" src="webcam.js"></script>
   
   
   <script language="JavaScript">
      Webcam.set({
         width: 600,
         height: 460,
         image_format: 'jpeg',
         jpeg_quality: 90
      });
      Webcam.attach( '#live_camera' );
   </script>
   
   
   <form>
      <input type=button value="Take Snapshot" onClick="get_take_snap()">
   </form>
   
   
   <script language="JavaScript">
      function get_take_snap() {
         // Simple call the take some your selfi and some get your live image data
         Webcam.snap( function(data_uri) {
            // display img_output in page
            
               
            Webcam.upload( data_uri, 'storeImage.php', function(code, text) {
               document.getElementById('img_output').innerHTML = 
               '<h2>Here is your Display image:</h2>' + 
               '<img src="'+text+'"/>';
            } );   
         } );
      }
   </script>
   
</body>
</html>

PHP 代码

<?php
$myfilename =  time() . '.jpg';
$livefilepath = 'upload/';
move_uploaded_file($_FILES['webcam']['tmp_name'], $livefilepath.$myfilename);
echo $livefilepath.$myfilename;
?>
4

1 回答 1

2

托管服务提供商的服务器管理团队解决了这个问题。为此完成了来自后端的完整权限修复,以便修复所有权限,包括根目录。

于 2020-10-08T11:32:03.313 回答