PDA

View Full Version : Apache MIME Types - Confused



WarNox
25-08-2009, 11:09 PM
Hey!

On my webserver, if I put a .jpg file in a directory I can access it fine through a web browser. ie. the picture displays in the browser. On the other hand, if I put a .bmp file in a directory the file downloads, it does not display.

I figure this is to do with MIME types.

I tried adding:

AddType image/bmp .bmp

to:

/etc/apache2/apache2.conf
/etc/apache2/httpd.conf

But neither did anything.

I found the current MIME types file in:

/etc/mime.types

and that file already has an entry for 'bmp' files:

image/x-ms-bmp bmp

So I'm not sure why it isn't working. Anyone have any idea what the problem is?

Thanks,



Gregor

Ross Burgess
26-08-2009, 09:21 AM
So you can see it download but not see the image?
what web browser are you using?
Thanks

WarNox
26-08-2009, 11:29 AM
Yeah the image will download rather than display in the browser. Happens with any browser I use, IE, Chrome etc etc

I need to somehow tell Apache to display the image in the browser rather than downloading it.

DeSade
26-08-2009, 12:25 PM
Just to state the obvious. BMP is large and cumbersome why not convert the format?

WarNox
26-08-2009, 02:16 PM
That's not the point :) I can convert the file and that works but why doesn't .bmp work. I do not want to work with BMPs but would like to know how to fix the issue regardless.

Erayd
26-08-2009, 05:09 PM
Can you please post a dump of the headers the server is sending?

If you don't know how to do this, a public link to the image will suffice - I can grab them from that.

WarNox
26-08-2009, 10:39 PM
PM sent.

Erayd
26-08-2009, 10:48 PM
Request headers:
GET /example.bmp HTTP/1.1
User-Agent: Opera/9.80 (X11; Linux x86_64; U; en) Presto/2.2.15 Version/10.10
Host: example.com
Accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1
Accept-Language: en
Accept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1
Accept-Encoding: deflate, gzip, x-gzip, identity, *;q=0
Cache-Control: no-cache
Connection: Keep-Alive, TE
TE: deflate, gzip, chunked, identity, trailers
Response headers:
HTTP/1.1 200 OK
Date: Wed, 26 Aug 2009 09:42:05 GMT
Server: Apache/2.2.11 (Ubuntu) PHP/5.2.6-3ubuntu4.2 with Suhosin-Patch
Last-Modified: Wed, 26 Aug 2009 09:34:26 GMT
ETag: "4de23-1dfb36-47208282a2c80"
Accept-Ranges: bytes
Content-Length: 1964854
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: image/x-ms-bmp

WarNox
26-08-2009, 11:00 PM
Sorry, I don't get it, what does that tell me? I can see in the GET request that there is the content type of image/x-ms-bmp, so why does the image still download rather than display?

Thanks again!

Erayd
26-08-2009, 11:05 PM
Apologies for the delay in this reply - TelstraClear had some cable outages in my area this evening, and my net access dropped right after posting the headers.

That all looks pretty good. While you're using a nonstandard mimetype (the standard one is image/bmp), the one you have is pretty commonly accepted.

I have also tested in both Opera and Firefox - both are quite happy to display the image. Are you sure the problem isn't with the system you're trying to view it on?

Which browsers are you testing in?

Can you view bitmap images on other sites?

WarNox
26-08-2009, 11:28 PM
Well this is strange.

With Chrome, internally the image just downloads. With IE, internally and from one Terminal Server the image is automatically opened with Paint.

If I browse to a .bmp on a geocities hosted website, with Chrome the image displays in the browser.

With Firefox, from another machine internally, the image displays in the browser.

I don't really get this. What's going on :badpc:

Erayd
26-08-2009, 11:32 PM
What happens if you change the server mimetype to image/bmp (this is the technically correct one) - does it fix the issue?

WarNox
26-08-2009, 11:50 PM
Ok, I changed the mime type in /etc/mime.types to image/bmp and restarted apache. Everything still looks the same from this end. Do you mind doing another GET request as before just to see if the Content-Type changes. Sorry, I'm not sure how to do this.

Thanks,



Gregor

Erayd
27-08-2009, 01:57 AM
Content-type header has changed to image/bmp, the image still loads fine.
HTTP/1.1 200 OK
Date: Wed, 26 Aug 2009 12:56:39 GMT
Server: Apache/2.2.11 (Ubuntu) PHP/5.2.6-3ubuntu4.2 with Suhosin-Patch
Last-Modified: Wed, 26 Aug 2009 09:34:26 GMT
ETag: "4de23-1dfb36-47208282a2c80"
Accept-Ranges: bytes
Content-Length: 1964854
Keep-Alive: timeout=15, max=99
Connection: Keep-Alive
Content-Type: image/bmp

Erayd
27-08-2009, 02:00 AM
Just another thought - does it only happen with a large file, or do small (<200KB) files have the same issue? The file you're testing with is 1.9MB, which might be causing the browser to decide to download it instead.

WarNox
27-08-2009, 09:47 AM
Cool, thanks for that. At least now I know that is the correct mime types file.

---

This morning I did as you suggested and put up a small and large BMP file but both loaded fine. I'm guessing there would have been something in cache last night with the browsers I was testing with and the issue was solved by changing the mime type to image/bmp, does that make sense?

Also, how did you get that HTTP request? I'd like to know for future testing.

Thanks,



Gregor

Erayd
27-08-2009, 10:24 AM
Also, how did you get that HTTP request? I'd like to know for future testing.
As I explained in my PM to you, I used Opera Dragonfly to grab the headers - although there are also several other possible ways of doing it.

WarNox
27-08-2009, 12:04 PM
Sorry, did not see the PM. Thanks for all your help man!!