我尝试一些代码将网络摄像头图像存储到文件夹中,并将图像路径存储到MySql
数据库中。在此图像路径存储在数据库中,但是图像未存储在指定的文件夹中。所以请帮我解决这个问题。
HTML
<div class="form-group">
<label class="control-label col-lg-3" for="snopshot">Profile</label>
<div class="col-lg-9">
<div id="results" name="image"></div>
<div id="my_camera"></div>
<input type=button value="Take Snapshot" name="image" onClick="take_snapshot()">
</div>
</div>
JavaScript
<script language="JavaScript">
function take_snapshot() {
// take snapshot and get image data
Webcam.snap( function(data_uri) {
// display results in page
document.getElementById('results').innerHTML =
'<h2></h2>' +
'<img src="'+data_uri+'"/>';
} );
}
<script language="JavaScript">
Webcam.set({
width: 200,
height: 150,
image_format: 'jpeg',
jpeg_quality: 90
});
Webcam.attach( '#my_camera' );
</script>
php
<?php
$path = '/uploads/'.date('YmdHis').rand(383,1000).'.jpg';
move_uploaded_file($_FILES['webcam']['tmp_name'], $path);
mysqli_query($con,"INSERT INTO patreg(profile)
VALUES('$path')")or die(mysqli_error($con));
?>