"内容类型:文本/无格式"强制下载文件 [英] "Content-Type:text/plain" forces to download the file
问题描述
如果我调用 header('Content-Type:text / plain; charset = ISO-8859-15');
浏览器将下载文件而不是显示它。使用 text / html
来代替。 (无论如何处理下载的文件,它不会下载源代码)
我试着添加头('Content-Disposition:inline ;');
但它被忽略。
我对于可能导致此问题的任何提示非常无知?
服务器是MAMP 1.9.6(PHP 5.3.5,Apache / 2.0.64)。
编辑:this只能在Chrome上发生,它可以在Firefox,Camino和Safari上运行。 我不能用这个脚本重现这一点:
>' <?php
header('Content-Type:text / plain; charset = ISO-8859- 15' );
回声这是一些文字;
然而,我可以用它重现它:
<?php
header('Content-Type:text / plain; charset = ISO-8859-15');
echo\x00This是一些文字;
确保您的内容实际上是纯文本的ASCII文本...
If I call header('Content-Type:text/plain; charset=ISO-8859-15');
the browser will download the file instead of showing it. Using text/html
works instead. (the downloaded file is processed anyway, it's not downloading the source code)
I've tried to add header('Content-Disposition:inline;');
but it was just ignored.
I'm pretty clueless about what could cause this problem, any tip?
The server is MAMP 1.9.6 (PHP 5.3.5, Apache/2.0.64).
edit: this only happens on Chrome, it works on Firefox, Camino and Safari.
I cannot reproduce this with this script:
<?php
header('Content-Type:text/plain; charset=ISO-8859-15');
echo "This is some text";
However, I can reproduce it with this:
<?php
header('Content-Type:text/plain; charset=ISO-8859-15');
echo "\x00This is some text";
Make sure that your content actually is plain ASCII text...
这篇关于"内容类型:文本/无格式"强制下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!