http://blog.xuite.net/chihho32/blog/18147806
--
[PHP 檔案下載] 參考網址 http://blog.roodo.com/jaceju/archives/805389.html 用以下的方式,可以讓大部份瀏覽器 (主要是 IE) 詢問你是否要下載檔案 (而不是直接開啟) 。 $file_name = "file.name"; [PHP 讀大檔] $fp = fopen("sn.txt", "r"); [php寫入成 excel檔, 並可從網頁下載] header("Content-Disposition:filename=myfile.xls");
$file_path = "/path/to/realfile";
$file_size = filesize($file_path);
header('Pragma: public');
header('Expires: 0');
header('Last-Modified: ' . gmdate('D, d M Y H:i ') . ' GMT');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false);
header('Content-Type: application/octet-stream');
header('Content-Length: ' . $file_size);
header('Content-Disposition: attachment; filename="' . $file_name . '";');
header('Content-Transfer-Encoding: binary');
readfile($file_path);
?>
while (!feof($fp)) {
$content. = fgets($fp);
}
header("Content-type:application/vnd.ms-excel");
$content = "a \t b\t c\t d\n";
$content .= "e \t f\t g\t h\n";
echo $content;
?>
--
留言列表