phpヘッダーとreadfile関数を使用してWordファイルをダウンロードするときに問題が発生しました。Mozilla Firefoxでダウンロードしている間はうまく応答しますが、googlechromeとIEを使用しているときはうまく機能しません。この問題を解決するために私を案内してください。
これが私のコードです:
switch(strtolower($ext))
{
case "doc": $ctype="application/msword"; break;
case "docx": $ctype="application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break;
default: $ctype="application/octet-stream";
}
header('Content-Description: File Transfer');
//header("Content-type: application/octet-stream");
header("Content-Type: ".$ctype." ");
header('Content-Disposition: attachment; filename='.basename($rw['FINALDOCNAME']));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header('Pragma: private');
header('Content-Length: ' . filesize($rw['FINALDOCNAME']));
ob_clean();
flush();
readfile($filepath);