简体   繁体   中英

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

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...

对我来说,这有效:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM