簡體   English   中英

“Content-Type:text / plain”強制下載文件

[英]“Content-Type:text/plain” forces to download the file

如果我調用header('Content-Type:text/plain; charset=ISO-8859-15'); 瀏覽器將下載文件而不是顯示它。 使用text/html代替。 (無論如何處理下載的文件,它不下載源代碼)

我試圖添加header('Content-Disposition:inline;'); 但它只是被忽略了。

我對於什么可能導致這個問題,任何小費都很無能為力?

服務器是MAMP 1.9.6(PHP 5.3.5,Apache / 2.0.64)。

編輯:這只發生在Chrome上,適用於Firefox,Camino和Safari。

我不能用這個腳本重現這個:

<?php

  header('Content-Type:text/plain; charset=ISO-8859-15');
  echo "This is some text";

但是,我可以用這個重現它:

<?php

  header('Content-Type:text/plain; charset=ISO-8859-15');
  echo "\x00This is some text";

確保您的內容實際上純ASCII文本...

對我來說,這有效:

header('Content-Type:text/javascript;');

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM