Safari で多くの問題が発生しています。PHP スクリプトからのダウンロードを提供すると、ダウンロードしたファイルに「.html」拡張子が追加されます。クライアントに送信する HTTP ヘッダーにもかかわらず、インスペクターで変更されていることがわかりました。特に、MIME タイプは常に に設定されtext/html
ます。
ここで私がブラウザに送信しているもの:
<?php
....
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: public, must-revalidate, post-check=0, pre-check=0");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=\"{$file['name']}\"");
header("Content-Type: ".$file['type']?$file['type']:'application/octet-stream');
header("Content-Transfer-Encoding: binary");
header('Content-Length: ' . filesize($file['file']));
ob_end_flush();
@readfile($file['file']);
$file の内容:
$file = array(
'name'=>'myfile.zip',
'file'=>'/tmp/myfile.zip',
'type'=>'application/zip'
);
私に何ができる?