如何從php中的檔案夾下載檔案?我的表中有一行鏈接嗎? 我可以附加檔案并洗掉它們,但問題是我想下載檔案
<?php
foreach($file_data as $file)
{
if($file === '.' or $file === '..')
{
continue;
}
else
{
$path = $_POST["folder_name"] . '/' . $file;
$output .= '
<tr>
<td><img src="'.$path.'" height="50" width="50" /></td>
<td contenteditable="true" data-folder_name="'.$_POST["folder_name"].'" data-file_name = "'.$file.'" >'.$file.'</td>
<td><button name="remove_file" id="'.$path.'">Remove</button></td>
</tr>
';
}
}
$output .='</table>';
echo $output;
}
if($_POST["action"] == "remove_file")
{
if(file_exists($_POST["path"]))
{
unlink($_POST["path"]);
echo 'File Deleted';
}
}
?>
uj5u.com熱心網友回復:
您需要添加指向頁面的鏈接,在 href 屬性中指定所需檔案的路徑,并添加下載屬性。
<a href="files/doc.pdf" download>Download</a>
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/454863.html
上一篇:jquery按slab漲價
下一篇:如何在XML中搜索?(PHP)
