无法将图像数据转换为实际图像以在 html 表单上显示

问题描述 投票:0回答:0

我正在尝试在以 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";
  }
  ?>`
php base64 signature
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.