HTML5 Camera
The HTML Media Capture allows us to access the device's camera, this is especially useful for mobile divces. This new feature still a working draft, and so far I've only been able to use this technique using Android's browser.
NOTE: The image that you test with is not stored, I'm instead using Data URI to display the content of the uploaded image.
Allow some time for the image to upload after you hit submit.
Click here to view the demo in a page by itself.
(Source located under the demo)
PHP
<?php
$image = "";
if ( isset($_FILES["camera"]) && $_FILES["camera"]["tmp_name"] != "" ) {
$image = file_get_contents($_FILES["camera"]["tmp_name"]);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>HTML5 Camera by Samer Ziadeh</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<div>
<br />
<form method="post" action="#" enctype="multipart/form-data">
<div>
<input type="file" name="camera" id="camera" accept="image/*;capture=camera" />
<button type="submit">Submit</button>
</div>
</form>
<div>
<?php if ( $image != "" ) { ?>
<img src="data:image/jpeg;base64,<?php echo base64_encode($image);?>" alt="" width="300" />
<?php } ?>
</div>
</div>
</body>
</html>