[英]Php, files get bigger with full path name?
按照以下方式使用小型下载脚本:
$file = "$tempDir/download.zip";
if($file) {
header("Content-Disposition: attachment; filename=" . basename($file));
header("Content-Type: application/zip");
readfile($file);
}
当将此php脚本放置在下载源旁边,并仅使用“ download.zip”时,它可以正常工作,但否则,我会得到某种同名的垃圾文件,该文件为10 kb,而不是预期的1 kb
在您的代码中$ file始终== true
最好更换
if($file)
与
if(file_exists($file) && is_readable($file))
确保文件没有问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.