Merion
Merion

Reputation: 741

Browser downloads file instead of displaying it

I am using php readfile to send a file to the browser. Its is an image file. Howver the browser downloads it, instead of displaying it. This is the response header:

HTTP/1.1 200 OK
Date: Tue, 15 Jan 2013 14:11:46 GMT
Server: Apache
X-Powered-By: PHP/5.3.18-nmm1
Content-disposition: attachment; filename=test.jpg
Content-Length: 20599
Keep-Alive: timeout=1, max=100
Connection: Keep-Alive
Content-Type: image/jpeg; charset=binary

Why doesnt it display?

Upvotes: 1

Views: 2928

Answers (1)

Nippey
Nippey

Reputation: 4739

The bad guy is this line:

Content-disposition: attachment; filename=test.jpg

Try to remove it in order to show the image in the browser.

Alternatively, use a small html file, as this is the way a browser is supposed to work ;)

Upvotes: 2

Related Questions