I changed extension of text file to .jpg and tried to upload file. With IE7 mime type was recognized as text/plain and error "Mime Type mismatch" reported, but with Mozzila Firefox upload was completed.
imagefield: 5.x-2.x-dev
cck: 5.x-1.6-1
download method: public
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | New Text Document.jpg | 8 bytes | baja_tz |
Comments
Comment #1
dopry commentedcan you upload the image file you have trouble with here?
Comment #2
baja_tz commentedThis is ordinary txt file with changed extension to jpg. I'm concerned about it that someone can put anything with changed extension and it will be accepted like .bmp images which can't be resized. It's more problem in FF then in imagefield, because it doesn't read mime type. Little better solution is maybe to check first 8 bytes of file header like:
This isn't safe also because anyone can change header. There is PEAR extension for cheking file types but I'm not sure
is it common that it is installed on web servers. And one proposal if I may, for beggining to add extra check in your code for bmp files, something like this:
Thanks for reply and sorry about my english :)
Comment #3
dopry commentedumm yeah you can put any extension on a file and upload it... we only check extension... browser mimes can be spoofed too. See the mimedetect.module if you want server side mime type detection. It however will not be integrated with imagefield.