我有一个来自数据库的表。我想为
创建下载恢复列
在表中,它应该下载或查看该特定的行文件。我该怎么办。
jobs.php
<div class="col-md-8 col-md-offset-2">
<h3 style="text-align: center">Job Application Submitted</h3>
<table>
<thead>
<tr class="table-headers">
<th>Name</th>
<th>Email</th>
<th>Phone</th>
<th>job Applied For</th>
<th>Resume</th>
</tr>
</thead>
<tbody>
<?php include('config.php');
$sql = "SELECT * FROM apply_job order by id ASC";
$result = mysqli_query($db,$sql);
if(mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_assoc($result))
{
?>
<tr>
<td><?php echo $row['template-jobform-fname']?></td>
<td><?php echo $row['template-jobform-email'];?></td>
<td><?php echo $row['template-jobform-phone'];?></td>
<td><?php echo $row['job_name'];?></td>
<td><a href="<?php echo $row['template-jobform-application']?>" target="_blank" ><?php echo $row['template-jobform-application'];?></a></td>
</tr>
<?php
}
}
?>
</tbody>
</table>
</div>
我想要下载特定文件,即如果我更新第二行并下载第二行简历,则应该下载该特定简历而不是全部。我该怎么办。
答案 0 :(得分:1)
Use sample function below for file download
<?php
function fileDownload($filename, $filepath)
{
$filepath = $filepath . "/" . $filename;
header("Cache-control: private");
header("Content-type: application/force-download");
header("Content-transfer-encoding: binary\n");
header("Content-disposition: attachment; filename=\"$filename\"");
header("Content-Length: " . filesize($filepath));
readfile($filepath);
}
答案 1 :(得分:0)
您可以这样创建下载链接:
<a href="<?php echo $row['template-jobform-application']?>" download ><?php echo $row['template-jobform-application'];?></a>
请注意,标记定义中存在download
属性,该属性指定应在单击时下载目标。