从数据库中提取记录后,我无法下载特定记录 如果我使用此代码,我只能下载该文件,但是在获取数据后,如果我点击任何下载按钮,则只下载与该记录相关的特定文件。
这是我的代码:
HTML:
<table>
<thead>
<tr>
<th scope="col">S.No</th>
<th scope="col" style="align:center;">Title</th>
<th scope="col">Image</th>
<th scope="col" style="width: 95px;">Modify</th>
</tr>
</thead>
<tbody>
<?php include "image.php" ;
while($row = mysql_fetch_array($result)) {
?>
<?php
$r=$row['blog_title'];
$string=str_replace('-',' ', $r);
?>
<tr>
<td><?php echo $row['blog_id'];?></td>
<td><?php echo $string;?></td>
<td><?php if($row['image']) echo "<img src='upload/".$row['image']."' height='100' weight='100' />"; ?></td>
<td><a class="buttons delete" href="deleteblog.php?id=<?php echo $row['blog_id'];?>" >Delete Blog</a></td>
$file = "logo_ldg.png";
<td><a class="buttons delete" href="download.php?nama=".$file."' >Download</a></td>
</tr>
<?php
}
?>
</tbody>
</table>
的download.php
<?php
$name= $_GET['nama'];
header('Content-Description: File Transfer');
header('Content-Type: application/force-download');
header("Content-Disposition: attachment; filename=\"" . basename($name) . "\";");
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($name));
ob_clean();
flush();
readfile("your_file_path/".$name); //showing the path to the server where the file is to be download
exit;
?>