相关疑难解决方法(0)

我是否需要Content-Type:application/octet-stream进行文件下载?

HTTP标准说:

如果在带有application/octet-stream内容类型的响应中使用此标题[Content-Disposition:attachment],则隐含的建议是用户代理不应显示响应,而是直接输入`save response as .. '对话.

我读到了

Content-Type: application/octet-stream
Content-Disposition: attachment
Run Code Online (Sandbox Code Playgroud)

不过,我本来以为Content-Typeapplication/pdf,image/png等等.

Content-Type: application/octet-stream如果我想要浏览器下载文件,我应该有吗?

browser http download http-headers

383
推荐指数
1
解决办法
47万
查看次数

从php脚本返回时,你如何支持寻找mp3?

我的服务器上有一个mp3(网址只是示例):

http://www.my-server.com/myaudio.mp3
Run Code Online (Sandbox Code Playgroud)

我在服务器上有一个php脚本:

http://www.my-server.com/testmp3.php
Run Code Online (Sandbox Code Playgroud)

其中包含以下代码(我在这里得到):

<?
$file = "myaudio.mp3";

if (file_exists($file)) {
  header('Content-Description: File Transfer');
  header('Content-Type: application/octet-stream');
  header('Content-Disposition: attachment; filename='.basename($file));
  header('Content-Transfer-Encoding: binary');
  header('Expires: 0');
  header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  header('Pragma: public');
  header('Content-Length: ' . filesize($file));
  ob_clean();
  flush();
  readfile($file);
  exit;
}
?> 
Run Code Online (Sandbox Code Playgroud)

这是我必须做的所有模仿行为,以便两个请求的行为方式相同,并返回完全相同的响应?或者有什么我想念的.

我在iOS上使用了一些流媒体代码(这里不相关),并且这两个请求都传输了音频,但是我无法正确使用php请求,但我可以直接使用mp3请求.

因此,在没有详细了解应用程序本身的情况下,我想首先消除这个变量.有什么我需要做的,以确保从另一个应用程序的角度来看这两个请求将返回完全相同的数据?

感谢您的任何意见,您可以在这里给我.

更新

事实证明,我的问题应该是"从php脚本返回时你如何支持寻找mp3?".

php http file request

9
推荐指数
1
解决办法
2222
查看次数

标签 统计

http ×2

browser ×1

download ×1

file ×1

http-headers ×1

php ×1

request ×1