为什么Safari / WebKit会将.html附加到下载的文件中?

时间:2013-05-05 09:44:50

标签: php http safari download mime

我在Safari方面遇到很多问题。当我从PHP脚本提供下载时,下载的文件附加了“.html”扩展名。尽管我发送给客户端的HTTP标头,我发现它们在检查员中发生了变化;特别是mime-type总是设置为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'
);

我该怎么办?

0 个答案:

没有答案