请问各位
以下是我从网络上找到的标准范例,
不知哪边错误,我的页面都无法成功下载档案呢。
PS. 确定档案有产生
$handle = fopen("file.txt", "w");
fwrite($handle, "text1.....");
fclose($handle);
$url = "http://localhost/file.txt";
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename('file.txt'));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize('file.txt'));
readfile('file.txt');
exit;