I create the Signature Pad using https://laratutorials.com/signature-pad-php-mysql-jquery/. The problem is when I click submit, the signature image path can't save into database.
Here is the code for 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.";
?>
Any one can help?
CodePudding user response:
sign field in mysql database change varchar to text field it can store in database
CodePudding user response:
In the SQL statement
$sql="INSERT INTO works (sign) VALUES ('$file') WHERE id=1";
you don't need WHERE id=1, it is actually an error.
you should check the return value of mysqli_query()
