【发布时间】:2013-07-27 14:43:16
【问题描述】:
我有一个下载 zip 文件的代码:
$dl_path = './';
$filename = 'favi.zip';
$file = $dl_path.$filename;
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/zips');
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-Type:application/download");
header("Content-Disposition:attachment;filename=$filename ");
header("Content-Transfer-Encoding:binary ");
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
有根目录/public_html,脚本在根目录下执行。
/ 目录中有 zip 文件。
我正在尝试将$dl_path 用作/,但它不起作用。
请帮忙。
【问题讨论】:
-
1.正确格式化您的代码; 2. 使用 ../ 作为在 public_html 下方移动的路径