此片段应通过web服务器将文件tiff或modi传输给用户。
header('Content-Description: File Transfer');
header('Content-Type: ' . $file_mime_type);
header('Content-Disposition: attachment; filename="' . $file_name . '"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . $file_size);
# till this moment all is fine
echo file_get_contents("path/to/file.tif");
# script fails on line above, and doesnt reach this place当文件格式不是tiff或modi时,所有文件都工作正常,客户端浏览器开始下载文件(docx/xlsx/pdf/等等)当用户试图下载tiff或modi时,脚本就会失败,不会出现任何错误。用print(file_get_contents("path/to/file.tif"));和readfile("path/to/file.tif");代替了echo,结果是一样的。
发布于 2017-09-25 14:05:12
当我开始使用“通用”内容类型时,所有操作都很好
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream'); //universal Content-Type
header('Content-Disposition: attachment; filename="' . $file_name . '"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . $file_size);
echo file_get_contents("path/to/file.tif");https://stackoverflow.com/questions/45677330
复制相似问题