无法从数据库中提取BLOB

时间:2016-04-12 18:01:52

标签: php mysql web wamp

我正在使用wamp服务器和phpmyadmin和php来实现我的数据库应用程序。我已将BLOB文件存储在数据库中。但我无法以原始格式提取blob文件,并允许用户以原始格式下载它。有人能帮帮我吗?我附上了从数据库中提取blob格式的截图。

enter image description here

还附加了从数据库中提取的代码。该代码提取除了BLOBS之外的所有内容。请有人帮助我。

foreach($_POST['passport'] as $entry) 
{
    $sql = "SELECT $entry FROM passport WHERE UID = '$j'";
    $a = mysqli_query($conn,$sql);
    $b = mysqli_fetch_array($a);
    $c = $b[0];
    echo "<tr><td>{$entry}</td><td>$c</td></tr>";
}

The screenshot of the image as I have mentioned in my comment

1 个答案:

答案 0 :(得分:0)

试试这个:

foreach ($_POST['passport'] as $entry) 
{
    $sql = "SELECT $entry FROM passport WHERE UID = '$j'";
    $a = mysqli_query($conn,$sql);
    $b = mysqli_fetch_array($a);
    $c = $b[0];
    echo '<tr><td><img src="data:image/jpeg;base64,' . base64_encode($entry) . '"></td><td>' . $c . '</td></tr>';
}