我在名为 template.doc 的本地服务器中存储了一个示例文档。然后我将文件目录存储在我的 sqlite 表中。我设法调出文件目录的路径,但我怎样才能让用户下载它?
代码
<form id="List" name="List" method="post" action="">
<select name="List" id="List">
<?php
if ($Choice !="No")
{
$path = $_SERVER['DOCUMENT_ROOT']."/WEB/";
$fullPath = $path.$_GET['$Choice'];
echo "<form id=\"form7\" name=\"form7\" method=\"post\" action=\"\">";
echo "<input type=\"submit\" name=\"Download\" id=\"Download\" value=".$fullPath."/>";
if (file_exists($fullPath))
{
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($fullPath));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($fullPath));
ob_clean();
flush();
readfile($fullPath);
echo "<label>".$fullPath."</label>";
echo "<input type=\"submit\" name=\"Download\" id=\"Download\" value=".$fullPath."/>";
exit;
echo '</form>';
}
}
?>
如何在列表表单下方创建一个按钮并下载 microsoft word?它现在会在网站上清除 Microsoft Word 文本,而不是在按钮上。请告知是否可以这样做。仅用于本地测试。非常感谢!