Php,使用完整路径名的文件会变大吗?
使用一个小的下载脚本,内容如下:Php,使用完整路径名的文件会变大吗?,php,download,Php,Download,使用一个小的下载脚本,内容如下: $file = "$tempDir/download.zip"; if($file) { header("Content-Disposition: attachment; filename=" . basename($file)); header("Content-Type: application/zip"); readfile($file); } 当这个php脚本放在下载源旁边,并且只使用“download.zip”时,它就可以正常
$file = "$tempDir/download.zip";
if($file) {
header("Content-Disposition: attachment; filename=" . basename($file));
header("Content-Type: application/zip");
readfile($file);
}
当这个php脚本放在下载源旁边,并且只使用“download.zip”时,它就可以正常工作了
但除此之外,我会得到一些同名的垃圾文件,它是10KB,而不是代码中预期的1KB。$file总是==true 最好换个新的
if($file)
与
确保文件正常。下载的“垃圾”文件可能包含PHP错误,这对发现解决方案非常有用。如果您尝试使用文本编辑器打开它,它可能会帮助您找出问题所在:-)
if(file_exists($file) && is_readable($file))