这已经发布,但我已经尝试了很多在 SO 上找到的解决方案等等(比如:http ://davidwalsh.name/php-force-download )
我基本上有这个:
{
$filePath = '../public/myfile.png';
$fileName = basename($filePath);
$fileSize = filesize($filePath);
if (!is_file) {
die("File not found");
} else {
header("Content-Description: File Transfer");
header('Content-Type: application/octet-stream');
header("Content-Disposition: attachment; filename= " . $fileName);
header("Content-Transfer-Encoding: binary");
readfile($filePath);
}
}
文件被识别并下载,但 .PNG 为空且 .DOC 已损坏(Word 要求我修复文件,然后就可以了)。我也试过PDF,没问题。
我确实可以放置各种选项(Pragma,Cache-Control,Expires,Content-Length 等),仍然下载文件但以某种方式损坏......
你有没有遇到过我的问题?请考虑我在 IIS 7.5 上
提前致谢