从网络摄像头保存图像在本地主机上工作正常但在服务器上不工作
Saving image from webcam works fine in local host but not on server
以下是我的代码。它在本地主机上运行良好。不知何故,当我将其上传到服务器图像时,无法保存。
index.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;
?>
托管服务提供商的服务器管理团队解决了该问题。为此后台做了完整的权限修复,所以包括根目录在内的所有权限都被修复了。
以下是我的代码。它在本地主机上运行良好。不知何故,当我将其上传到服务器图像时,无法保存。
index.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;
?>
托管服务提供商的服务器管理团队解决了该问题。为此后台做了完整的权限修复,所以包括根目录在内的所有权限都被修复了。