Re: FW: mime-type related to extension?. .

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



meal list_php wrote:
Hi I sent this on 21st of april and got no answer...
there is no way to check the "real" mime type of a file?
even a file without extension?
thanks,

You can call out to an external program called "file" (which is pretty much guaranteed to be there, on a Linux system) which uses some magic to determine the file type. It should be able to tell you if the file is jpeg regardless, without any messy work from you. It will return a string like so:
$ file false.doc
false.doc: JPEG image data, JFIF standard 1.02
I'd run a few tests with some images from different sources, but it should be returning a very standard string - "JPEG image data" should at least be common. IIRC Sony also has a 'motion jpeg' which might cause you problems, depending on what you're doing - if you can get a hold of one of those to test (if it's a concern) you might want to.


cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International Outreach x3257
The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital.


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux