Home  >  Q&A  >  body text

The signature image path cannot be saved to the database

I use https://laratutorials.com/signature-pad-php-mysql-jquery/ to create the signature pad. The problem is that when I click submit, the signature image path is not saved to the database.

This is the code of upload.php

<?php
include_once '../db_connect.php';

$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;
$sql="INSERT INTO works (sign) VALUES ('$file') WHERE id=1";
mysqli_query($con,$sql);
  
file_put_contents($file, $image_base64);
echo "Signature Uploaded Successfully.";
?>

Can anyone help?

P粉388945432P粉388945432245 days ago297

reply all(1)I'll reply

  • P粉402806175

    P粉4028061752024-02-18 09:52:07

    The sign field in mysql database changes varchar to Text fieldcan be stored in the database

    reply
    0
  • Cancelreply