Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script src="webcam.js"></script> <!--source code script from github for webcam config-->
- <div id="my_camera" style="width:320px; height:240px;"></div>
- <div id="my_result"></div>
- <script type=text/javascript>
- Webcam.attach( '#my_camera' );
- function take_snapshot() {
- Webcam.snap( function(data_uri) {
- document.getElementById('my_result').innerHTML = '<img src="'+data_uri+'"/>';
- } );
- }
- </script>
- <a href="javascript:void(take_snapshot())">Take Snapshot</a>
- <?php
- session_start();
- include_once'database.php';
- $uid = $_SESSION['u_id'];
- if (isset($_POST['submit'])){
- $file = $_FILES['file'];
- $fileName = $_FILES['file']['name'];
- $fileTmpName = $_FILES['file']['tmp_name'];
- $fileSize = $_FILES['file']['size'];
- $fileError = $_FILES['file']['error'];
- $fileType = $_FILES['file']['type'];
- $fileExt = explode('.', $fileName);
- $fileActualExt = strtolower(end($fileExt));
- $allowed = array('jpg', 'jpeg', 'png');
- //check if ang uploaded file allowed i upload//
- if (in_array($fileActualExt, $allowed)){
- if ($fileError == 0){
- if ($fileSize < 1000000){
- $fileNameNew = "profile".$uid.".".$fileActualExt;
- $fileDestination = 'uploads/'.$fileNameNew;
- move_uploaded_file($fileTmpName, $fileDestination);
- $sql = "UPDATE profileimg SET status=0 WHERE userID ='$uid';";
- $result = mysqli_query($conn, $sql);
- header("location:../pages/userpage.php");
- }
- else {
- echo "Your file is too big";
- }
- } else {
- echo "There was an error uploading you file!";
- }
- } else {
- echo "You cannot upload files of this type";
- }
- }
- Webcam.upload( data_uri, 'myscript.php', function(code, text) {
- // Upload complete!
- // 'code' will be the HTTP response code from the server, e.g. 200
- // 'text' will be the raw response content
- } );
- } );
- move_uploaded_file($_FILES['webcam']['tmp_name'], 'webcam.jpg');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement