我喜歡這個PHP:強制下載後顯示內容?
<?php
if (file_exists("./foo.txt")) {
header("Content-type: application/force-download");
header("Content-length: ".filesize("./foo.txt"));
header('Content-Disposition: attachment; filename="foo.txt"');
readfile('./foo.txt');
}
print "HEY!";
?>
一個劇本,我想「嗨」被強制下載後寫入網頁,這怎麼可能?
我看到像「如果你的下載沒有自動啓動,請點擊」下載的網頁,所以它的內容和下載?我的示例中的hey
包含在文本文件中,因此不起作用。
+1爲老學校:) – 2014-09-30 06:23:45