首页  >  问答  >  正文

签名图片路径无法保存到数据库

我使用 https://laratutorials.com/signature-pad-php-mysql-jquery/ 创建签名板。 问题是当我点击提交时,签名图像路径无法保存到数据库中。

这是 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.";
?>

有人可以帮忙吗?

P粉388945432P粉388945432245 天前299

全部回复(1)我来回复

  • P粉402806175

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

    mysql数据库中的sign字段将varchar更改为文本字段可以存储在数据库中

    回复
    0
  • 取消回复