Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 577
o0'. Avatar asked Oct 24 '11 14:10

o0'.


People also ask

What is the content type for plain text?

The text/plain content type is the generic subtype for plain text. It is the default specified by RFC 822. The text/RFC 822-headers content type provides a mechanism for a Message Transfer Agent (MTA) to label and return only the RFC 822 headers of a failed message.

How do I download text data from a website?

Click and drag to select the text on the Web page you want to extract and press “Ctrl-C” to copy the text. Open a text editor or document program and press “Ctrl-V” to paste the text from the Web page into the text file or document window. Save the text file or document to your computer.


1 Answers

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

like image 56
DaveRandom Avatar answered Sep 29 '22 10:09

DaveRandom