相关疑难解决方法(0)

移动设备的HTTP标题"Content-Type:application/force-download"的效用?

我目前正在开发一个PHP脚本,允许您通过访问链接从移动设备下载媒体内容(视频,音频,图片...).(即http://www.my-web-site.com/download.php?id=7ejs8ap)当我用最近的手机(三星Galaxy S,iPhone 4S,其他一些人)测试时,我的脚本非常有用. )但我的旧手机三星C3050出现错误.我想下载的媒体只是一个音频mp3文件,我通常很容易下载.

该错误似乎是"未知内容类型".因此,由于我唯一的HTTP标头Content-Type是"application/force-download",我尝试对此进行评论并再试一次.然后,它的工作原理.但是现在,我目前正在询问这种内容类型的含义以及是否可以强制其他移动设备.我在iPhone 4上没有使用Content-Type进行测试,但它确实有效,但我不确定所有移动设备的兼容性.

有人可以解释一下Content-Type是如何工作的,为什么这不是标准的MIME或其他所有可以帮助我确保这是每个下载的选项内容类型,无论文件,浏览器或设备是什么我正在下载?

感谢大家.

这是我发送的PHP标头:

<?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);
?>
Run Code Online (Sandbox Code Playgroud)

编辑:我刚试过索尼Xperia,下载不成功:我只看到我要下载的文件的"html编码"字节.如果application/octet-stream或application/force-download不起作用,我怎么知道我必须使用哪种内容类型?

php mobile content-type http download

40
推荐指数
2
解决办法
9万
查看次数

标签 统计

content-type ×1

download ×1

http ×1

mobile ×1

php ×1