我有一個日誌文件,它在Linux操作系統中給出了正確的格式,但在Windows中它沒有格式化。新行字符無法讀取。我只能在閱讀/下載文件時進行更改。請建議解決方案如何在文件讀取時添加/ r/n php
if(isset($_REQUEST['download'])) {
$file = $dir . "/" . basename($_REQUEST['download']);
if (file_exists($file)) {
ob_start();
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header("Pragma: no-cache");
header("Expires: 0");
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
}
'\ r \ n'不是'/ r/n'。 – v7d8dpo4