错误显示为“未知内容类型”。 因此,由于我的唯一HTTP头Content-Type是“application/force-download”,我尝试注释它然后再试一次。 然后,它就可以工作了。 但现在,我正在询问这个Content-Type是什么意思,它是否对其他手机必需。 我在iPhone 4上测试过没有Content-Type也可以工作,但是我不确定所有移动设备是否兼容。
有人能解释一下Content-Type如何工作,为什么这不是标准MIME或任何其他能帮助我确保对于任何下载,无论文件、浏览器或我正在下载的设备来说都是可选的Content-Type吗?
谢谢大家。
这是我发送的 PHP headers:
<?php
//Assume that $filename and $filePath are correclty set.
header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename="'.$filename.'"');
// header('Content-Type: application/force-download'); Non-standard MIME-Type, incompatible with Samsung C3050 for example. Let it commented
readfile($filePath);
?>
编辑:我刚刚尝试了一下索尼Xperia,下载没有成功:我只看到了我想要下载的文件的“html编码”字节。如果application/octet-stream或application/force-download不起作用,我怎么知道我必须使用哪种content-type?
file --mime <filename>
。 - Mark E. Haase