javascript - how to store webcam captured image in specified folder and captured image path in mysql database using php..? -
i want capture image webcam user image image stored in specified folder , captured image path store mysql using php. have problem webcam captured image path not stored in mysql database. please me...
<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 , upload 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 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 write data $filename, check permissions\n"; exit(); } else { $sql="insert 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()"> <input type=button value="take snapshot" onclick="take_snapshot()"> </form> <div id="upload_results" style="background-color:#eee;"></div>
so saying works except "insert entry(images) values('$newname')"?
try echoing out full mysql error instead of brief "error in query". might table not exist, column not exist, has no auto-increment column, unnamed column has no default... anything.
Comments
Post a Comment