我有一个几年前的网站,它基本上提供下载。
无论如何,由于移动服务器人们无法下载文件,因为它现在给出错误 500 错误,并且在日志文件中它带来了这个错误:
来自脚本的格式错误的标头。错误的标头=1:index.php
无论如何,与此相关的唯一代码是:
// Echo $productOptionDetails->file;
$file = DOWNLOAD_FOLDER. '/'. $productOptionDetailEntity->file;
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file) + 1);
ob_clean();
flush();
readfile($file);
exit;
}
现在,如果我只是输出:
// Echo $productOptionDetails->file;
$file = DOWNLOAD_FOLDER. '/'. $productOptionDetailEntity->file;
if (file_exists($file)) {
readfile($file);
exit;
}
它输出大量加密文本,因此它显然在读取某些内容。
我读到的是标题不正确,但是在阅读了 php.net 以及其他网站中的大量内容之后,这看起来很好。
谁能大喊我为什么会收到这些错误?
谢谢