簡體   English   中英

從網絡攝像頭保存圖像在本地主機上工作正常但在服務器上不工作

[英]Saving image from webcam works fine in local host but not on server

以下是我的代碼。 它在本地主機上運行良好。 不知何故,當我將其上傳到服務器圖像時,無法保存。

索引.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;
?>

托管服務提供商的服務器管理團隊解決了這個問題。 為此從后端完成了完整的權限修復,以便修復所有權限,包括根目錄。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM