Displays.php
<?php
$connection = mysql_connect("localhost", "root", "");
mysql_select_db("toko_blog");
$sid = session_id();
$sql = mysql_query("SELECT * FROM bukti_transfer");
?>
<h1 class="Judul">Laporan</h1>
<table id="datatables" class="TableCart">
<thead>
<tr><th>No</th>
<th>Nama File</th>
<th>Gambar</th>
</tr>
</thead>
<tbody>
<?php
$no = 1;
while ($r=mysql_fetch_array($sql)){
echo"<tr><td>$no</td>";
echo"<td>$r[file_name]</td>";
echo'<td><img src="gambar.php?id='.$gambar['id'].'" width="150" /></td></tr>';
if($no % 4 == 0){
echo '</tr><tr>';
}
$no++;
}
?>
</tbody></table>
gambar.php
<?php
$connection = mysql_connect("localhost", "root", "");
mysql_select_db("toko_blog");
$idFile = $_GET['id'];
$dataGambar = mysql_fetch_array(mysql_query("select * from bukti_transfer where id='$idFile'"));
$filename = $dataGambar['file_name'];
$mime_type = $dataGambar['mime_type'];
$filedata = $dataGambar['file_data'];
header("content-disposition: inline; filename=$filename");
header("content-type: $mime_type");
header("content-length: ".strlen($filedata));
echo ($filedata);
?>
我想显示MySQL数据库中的图像。图像已保存在数据库中,但在显示时,图像已损坏。
我该如何解决?