javascript - How to store webcam captured image path in mysql database -
i've tried following code capture image, stores image in specified folder path of image want store in database doesn't work.the execution of code stops after uploding... message.please me,whats going wrong code.
<!--test.php--> <?php session_start(); include 'connection.php'; $name = date('ymdhis'); $newname=mysql_real_escape_string("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"; ?>
<!--index.php--> <?php session_start(); if(isset ($_post["send"])) { $getname=$_post["myname"]; include 'connection.php'; $idvalue=$_session["myvalue"]; $sql="update entry set name='$getname' id='$idvalue'"; $result=mysql_query($sql) or die(mysql_error()); if($result) { echo "uploaded $_session[myvalue] re ..... "; } else { echo "$_session[myvalue] nahi hua"; } } ?> <form action="<?php echo $_server["php_self"];?>" method="post"> <input type="text" name="myname" id="myname"> <input type="submit" name="send" id="send"> </form> <script type="text/javascript" src="webcam.js"></script> <script language="javascript"> document.write( webcam.get_html(320, 240) ); </script> <form> <input type=button value="configure..." onclick="webcam.configure()"> <input type=button value="take snapshot" onclick="take_snapshot()"> </form> <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> <div id="upload_results" style="background-color:#eee;"></div>
instead of giving relative path in file_get_contents()
give full path/actual path.
hope might you.
Comments
Post a Comment