繁体   English   中英

如何将网络摄像头捕获的图像存储在指定的文件夹中,并使用php将捕获的图像路径存储在mysql数据库中?

[英]how to store webcam captured image in specified folder and captured image path in mysql database using php..?

我想从网络摄像头用户图像中捕获图像,该图像存储在指定文件夹中,并使用php将捕获的图像路径存储到mysql中。 网络摄像头捕获的图像路径未存储在mysql数据库中时出现问题。 所以请帮我...

 <script type="text/javascript" src="webcam.js"></script> <script language="JavaScript"> document.write( webcam.get_html(320, 240) ); </script> <script language="JavaScript"> webcam.set_api_url( 'test.php' ); webcam.set_quality( 90 ); // JPEG quality (1 - 100) webcam.set_shutter_sound( true ); // play shutter click sound webcam.set_hook( 'onComplete', 'my_completion_handler' ); function take_snapshot(){ // take snapshot and upload to server document.getElementById('upload_results').innerHTML = '<h1>Uploading...</h1>'; webcam.snap(); } function my_completion_handler(msg) { // extract URL out of PHP output if (msg.match(/(http\\:\\/\\/\\S+)/)) { // show JPEG image in page document.getElementById('upload_results').innerHTML ='<h1>Upload Successful!</h1>'; // reset camera for another shot webcam.reset(); } else {alert("PHP Error: " + msg); } } </script> 
 ------------------------------------- ____________test.php_________________ <?php session_start(); include 'connection.php'; $name = date('YmdHis'); $newname="images/".$name.".jpg"; $file = file_put_contents( $newname, file_get_contents('php://input') ); if (!$file) { print "ERROR: Failed to write data to $filename, check permissions\\n"; exit(); } else { $sql="Insert into entry(images) values('$newname')"; $result=mysql_query($con,$sql) or die("Error in query"); $value=mysql_insert_id($con); $_SESSION["myvalue"]=$value; } $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['REQUEST_URI']) . '/' . $newname; print "$url\\n"; ?> 
 <form> <input type=button value="Configure..." onClick="webcam.configure()"> &nbsp;&nbsp; <input type=button value="Take Snapshot" onClick="take_snapshot()"> </form> <div id="upload_results" style="background-color:#eee;"></div> 

因此,您是说除“插入条目(图像)值('$ newname')”外,其他所有功能都有效吗?

尝试回显完整的mySQL错误,而不是简短的“查询错误”。 可能是表格不存在,列不存在,没有自动递增列,另一个未命名的列也没有默认值。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM