每次我使用下面的代码将图像文件流式传输给我时,文件会以损坏的形式返回。图像文件肯定没有腐败,当我通过我的ftp打开它时很好。我错过了什么吗?
$fileTry = imagecreatefromstring(file_get_contents($file_path));
if($fileTry === false)
{
die('no file');
}
else
{
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file_path));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file_path));
readfile($file_path);
exit;
}