不能转移或TIFF文件MODI用PHP
问题描述:
这个段应传输文件TIFF或作案从Web服务器,用户通过网络不能转移或TIFF文件MODI用PHP
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或作案,一切工作正常和客户端浏览器开始下载文件(docx/xlsx/pdf/etc。) 当用户尝试下载tiff或modi时,脚本失败而没有任何错误。 已尝试print(file_get_contents(“path/to/file.tif”));和readfile(“path/to/file.tif”);而不是回声,结果是相同的
答
当我开始使用“通用”的Content-Type,一切工作正常
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");
你有MIME类型在你的网络服务器设置为TIF? – raphael75
Yeap,配置中的所有类型都被正确设置了,为时间准备:) – otctynhuk