从网站下载文件PHP
答
请参阅here了解如何强制输出php脚本的下载。
它的基本功能是:
// Set headers
header("Cache-Control: public");
header("Content-Description: File Download");
header("Content-Disposition: attachment; filename=" + $filename);
header("Content-Type: application/zip"); // or whatever the mime-type is
// for the file you want to download
header("Content-Transfer-Encoding: binary");
// Read the file from disk
readfile($full_path_to_file);
作为补充(戈登的评论提供),请参见PHP文档here
答
一号例如在文件的结束或者点击使用文件,你可以添加此
$filesh = "check.xls";
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=".basename($filesh));
header("Content-Description: File Transfer");
readfile($filesh);
,如果你使用的问题意味着,)你可以添加ob_start文件的顶部(有任何头;功能
你是说,你想知道如何启动用户浏览你的网站文件下载? – Kazar 2010-04-16 09:05:11
对不起,这不是很清楚你想要什么。你可以尝试用不同的文字或例子来解释它吗? – deceze 2010-04-16 09:05:34
*(参考)* http://de2.php.net/manual/en/function.header.php(请参阅示例#1下载对话框) – Gordon 2010-04-16 09:08:47