* Martin Norland <[EMAIL PROTECTED]>: > 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.
An additional tool that may be used when simply checking for image types is to use getimagesize() -- though you should be using php >= 4.3.11 to do this safely (see http://security.gentoo.org/glsa/glsa-200504-15.xml for more information). One element returned by getimagesize() is the image MIME type. -- Matthew Weier O'Phinney | WEBSITES: Webmaster and IT Specialist | http://www.garden.org National Gardening Association | http://www.kidsgardening.com 802-863-5251 x156 | http://nationalgardenmonth.org mailto:[EMAIL PROTECTED] | http://vermontbotanical.org -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php