PHP Webcam Capture Image Save from Camera using jQuery

Today, We want to share with you PHP Webcam Capture Image Save from Camera using jQuery.In this post we will show you Capture Webcam Image with PHP and jQuery, hear for PHP Webcam Capture Image Database PHP Script to take Photo we will give you demo and example for implement.In this post, we will learn about capture image using webcam and save to database in php and html5 with an example.

PHP Webcam Capture Image Save from Camera using jQuery

There are the Following The simple About PHP Webcam Capture Image Save from Camera using jQuery Full Information With Example and source code.

As I will cover this Post with live Working example to develop capture image from webcam and store in database in php, so the some major files and Directory structures for this example is following below.

  • index.php
  • saveUploadImg.php

Step 1 : HTML Configuration and User Interface


This is where I will make a simple HTML form and PHP server side source code for our web application. To make the forms simply all souce code copy and write it into your any text editor Like Notepad++, then save file it as index.php.

<!DOCTYPE html>
    <title>Capture webcam image with php and jquery -</title>
    <script src=""></script>
    <script src=""></script>
    <link rel="stylesheet" href="" />
    <style type="text/css">
        #preview { padding:30px; border:1px solid; background:#3d3d3d; }
<div class="container">
    <h1 class="text-center">Capture webcam image with php and jquery -</h1>
	<p>Integrate Webcam Capture in a PHP Application</p>
    <form method="POST" action="saveUploadImg.php">
        <div class="row pakainfo">
            <div class="col-md-6 pakainfo">
                <div id="live_camera"></div>
                <input type=button value="Take Snapshot" onClick="capture_web_snapshot()">
                <input type="hidden" name="image" class="image-tag">
            <div class="col-md-6">
                <div id="preview">Your captured image will appear here...</div>
            <div class="col-md-12 text-center pakainfo">
                <button class="btn btn-primary pakainfo">Submit</button>
<!-- Settings a few settings and (php capture image from camera) web attach camera -->
<script language="JavaScript">
        width: 490,
        height: 390,
        image_format: 'jpeg',
        jpeg_quality: 90
    Webcam.attach( '#live_camera' );
    function capture_web_snapshot() {
        Webcam.snap( function(site_url) {
            document.getElementById('preview').innerHTML = '<img src="'+site_url+'"/>';
        } );

Step 2 : Save and Upload Images


    $myimg = $_POST['image'];
    $destinationPath = "upload/";
    $web_capture_part = explode(";base64,", $myimg);
    $image_type_aux = explode("image/", $web_capture_part[0]);
    $image_type = $image_type_aux[1];
    $image_base64 = base64_decode($web_capture_part[1]);
    $myimgName = uniqid() . '.png';
    $file = $destinationPath . $myimgName;
    file_put_contents($file, $image_base64);

Angular 6 CRUD Operations Application Tutorials

Read :


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about PHP Webcam Capture Image Save from Camera using jQuery.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Related FAQ

Here are some more FAQ related to this Article:

  1.   Create dynamic calendar using jQuery, Ajax and PHP
  2.   PHP Image Resize, Crop, Thumbnail, Watermark
  3.   CheckBox Show Hide Div using Angular Example
  4.   Capture Webcam Image with PHP and jQuery
  5.   jquery Pass PHP Laravel 5.6 Variables to Javascript
  6.   Create User Login System using C# Examples
  7.   Check if value exists jQuery in Array – jQuery.inArray()
  8.   PHP check laravel version using command
  9.   Getting Current Date Time in Vue.js Date Format
  10.   jQuery Capture Webcam Image Using Web Camera in PHP