Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 文件强制下载_Php - Fatal编程技术网

Php 文件强制下载

Php 文件强制下载,php,Php,我想强制下载。。在IE中,我得到一个错误,但FF中没有问题 header("Content-Type: application/force-download\n"); header("Content-Disposition: attachment; filename=test.txt"); echo 'test file'; 我刚才在谷歌上搜索了你好奇的应用程序/强制下载mime类型。我不知道,这是谁“发明”的,但它似乎并不存在。看 这意味着,IE可能不喜欢它。使用应用程序/octet流。据

我想强制下载。。在IE中,我得到一个错误,但FF中没有问题

header("Content-Type: application/force-download\n");
header("Content-Disposition: attachment; filename=test.txt");

echo 'test file';

我刚才在谷歌上搜索了你好奇的
应用程序/强制下载
mime类型。我不知道,这是谁“发明”的,但它似乎并不存在。看


这意味着,IE可能不喜欢它。使用
应用程序/octet流
。据我记忆所及,firefox会为每种mime类型打开一个下载对话框,要么注册为“show download dialog”,要么根本不知道。在这种情况下,FF可能不知道这种类型。

我只是在谷歌上搜索了一下你好奇的
应用程序/强制下载的
mime类型。我不知道,这是谁“发明”的,但它似乎并不存在。看


这意味着,IE可能不喜欢它。使用
应用程序/octet流
。据我记忆所及,firefox会为每种mime类型打开一个下载对话框,要么注册为“show download dialog”,要么根本不知道。在这种情况下,FF可能不知道类型。

这可能会对您有所帮助,它适合我

header('Content-Type: application/force-download');
header("Content-disposition: attachment; filename=$filename");
flush();
readfile($filename);
exit;

如果需要,您可以添加其他标题:)

这可能会对您有所帮助,它适合我

header('Content-Type: application/force-download');
header("Content-disposition: attachment; filename=$filename");
flush();
readfile($filename);
exit;

如果需要,您可以添加其他标题:)

mime类型的应用程序/强制下载是什么?你从哪弄来的?!o mime类型的应用程序/强制下载是什么?你从哪弄来的?!好的,但现在我不能预设文件名。。。标题(“内容类型:应用程序/八位字节流\n”);标题(“内容配置:附件;文件名=test.txt”);不知道,如果这是你行为的原因,但不要在结尾处换行。它有效,但现在我无法预设文件名。。。标题(“内容类型:应用程序/八位字节流\n”);标题(“内容配置:附件;文件名=test.txt”);不知道,如果这是你行为的原因,但不要在结尾加上换行符。在现代服务器代码中,我们应该避免
application/force download
,这是一个老黑客。在现代服务器代码中,我们应该避免
application/force download
,这是一个老黑客。