How to save signature in Mysql

  • Profile Image
    Asked on November 05, 2013 at 07:00 PM


    I am following the guide on saving my form to Mysql but am unsure as to how to save the signature which shows as

    data:image/png;base64 , is this just a blob, as it does not appear to save.

    I googled and established it as a method for being read by html.


  • Profile Image
    Answered on November 05, 2013 at 11:57 PM

    Hi there,

    You can use the following code to convert the base64 image string into an image file.


    function base64_to_jpeg( $base64_string, $output_file ) {

        $ifp = fopen( $output_file, "wb" ); 

        fwrite( $ifp, base64_decode( $base64_string) ); 

        fclose( $ifp ); 

        return( $output_file ); 


    //assign variable for your esignature post data, .e.g

    $my_base64_string = $_POST['signature4'];


    $esignature = base64_to_jpeg($my_base64_string, 'tmp.jpg' );

    There are few more scripts you can find at Google. If you require further assistance, do let us know here. Regards!

  • Profile Image
    Answered on November 06, 2013 at 12:01 AM

    Here is also a good one:

    Just let us know if you help with this. Thanks!