For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > April 2005 > mime-type related to extension?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author mime-type related to extension?
Mel List_php

2005-04-21, 3:56 pm

Hi guys!

I have a basic form to upload files, my problem is about the mime type.
I use $type= $_FILES[$file_uploaded]['type']; to check the mime-type of the
fila as I want to allow only .jpeg.
I have then a test like:
if ($type=="image/pjpeg" || $type=="image/jpeg")
{
....
}

Upload working fine if I send "red.jpg".
However if I rename the file in "red", php recognizes it as
application/octet-stream and not jpeg.
I'm working under linux and for me the extension is not required for a file,
I thought the mime-type was encoded in the file itself and was independent
of the extension.
Any clue on that?
Any other php function I should look at?
The cookbook and pear both use $_FILES[ ] ['type'] so I have no idea here.

Thanks,
Melanie

________________________________________
_________________________
It's fast, it's easy and it's free. Get MSN Messenger today!
http://www.msn.co.uk/messenger
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com