我正在尝试在以 Blob 类型存储在数据库中的表单上显示电子签名,到目前为止,我能够显示数据但无法将其转换为图像,任何帮助将不胜感激
这是我到目前为止得到的代码
`<?php
include('config.php');
// Prepare the SQL statement to select the signature data
$sql = "SELECT signatureData FROM details WHERE id = ?";
$stmt = $pdo->prepare($sql);
// Bind the ID parameter to the prepared statement
$id = 104; // Replace with the ID of the signature data to retrieve
$stmt->bindParam(1, $id, PDO::PARAM_INT);
// Execute the prepared statement
$stmt->execute();
// Fetch the result and return the base64-encoded signature data
$result = $stmt->fetch(PDO::FETCH_ASSOC);
if ($result) {
$signatureData = $result['signatureData'];
$imageData = base64_decode($signatureData);
$image = imagecreatefromstring($imageData);
// Output the signature data as an image
echo $image;
} else {
echo "No signature data found for ID $id";
}
?>`