【发布时间】:2013-08-08 16:59:27
【问题描述】:
添加标题是使链接可下载的方法已经有很好的记录,但我一定做错了什么。我编写文件,然后生成一些指向它的 HTML 链接,但文件不会下载,只会出现在浏览器中。
<?
//unique id
$unique = time();
$test_name = "HTML_for_test_" . $unique . ".txt";
//I should put the file name I want the header attached to here (?)
header("Content-disposition: attachment;filename=$test_name");
$test_handler = fopen($test_name, 'w') or die("no");
fwrite($test_handler, $test);
fclose($test_handler);
?>
<a href="<?=$test_name">Download File</a>
【问题讨论】:
标签: php