我在一个从根目录向上一级的目录中有ZIP文件(以防止盗链等)。下面是代码:在0字节处的PHP下载
<?php
$filename = $_GET['id'];
if(!$filename){
header("Location: index.html");
} else {
function send_download($filename){
$file_path = '../../../../downloads/' . $filename . '.zip';
[email protected]($file_path);
header("Content-Type: application/x-zip-compressed");
header("Content-disposition: attachment; filename=$filename");
header("Content-Length: $file_size");
readfile($file_path);
exit;
}
send_download($filename);
}
?>
所有的ZIP文件是罚款,但使用这种方法上的一个标签会导致下载到的文件大小为0字节! ?!:(
任何想法,为什么
非常感谢
您找不到路径或文件名。 – bfavaretto
为了测试起见,请在测试时使用文件大小($ file_path)中的文件的完整路径和GET RID OF HORRIBLE @! :) – Alfabravo
你也应该不声明函数为'IF-THEN-else'声明 – Touki