In this tutorial, We will learn how to use an e-signature pad using jquery ajax and save image to the database using PHP. 

Download E-Signature Pad Jquery plugin from here

Step 1:

Create index.php file and put the following code:

<!DOCTYPE html>
    <title>PHP Signature Pad Example</title>
    <link rel="stylesheet" type="text/css" href="">
    <script type="text/javascript" src=""></script> 
    <link type="text/css" href="" rel="stylesheet"> 
    <script type="text/javascript" src=""></script>
    <script type="text/javascript" src="asset/jquery.signature.min.js"></script>
    <link rel="stylesheet" type="text/css" href="asset/jquery.signature.css">
        .kbw-signature { width: 400px; height: 200px;}
        #sig canvas{
            width: 100% !important;
            height: auto;
<div class="container">
    <form method="POST" action="upload.php">
        <h1>PHP Signature Pad Example</h1>
        <div class="col-md-12">
            <label class="" for="">Signature:</label>
            <div id="sig" ></div>
            <button id="clear">Clear Signature</button>
            <textarea id="signature64" name="signed" style="display: none"></textarea>
        <button class="btn btn-success">Submit</button>
<script type="text/javascript">
    var sig = $('#sig').signature({syncField: '#signature64', syncFormat: 'PNG'});
    $('#clear').click(function(e) {

Step 2:

Create upload.php file 

    $folderPath = "upload/";
    $image_parts = explode(";base64,", $_POST['signed']); 
    $image_type_aux = explode("image/", $image_parts[0]);
    $image_type = $image_type_aux[1];
    $image_base64 = base64_decode($image_parts[1]);
    $file = $folderPath . uniqid() . '.'.$image_type;
    file_put_contents($file, $image_base64);
    echo "Signature Uploaded Successfully.";

Step 3:

Create upload directory where our signature file upload. This is destination directory.

Finally, Now you can run your application.

Are you facing problems in understanding this article?
You can watch the video. Watch it now