patmazuel — 2012-02-10T12:58:00-05:00 — #1
For my user transfer file routine, I only want them to be able to transfer pics or pdf.
I test the extension (jpg, jpeg, gif, png, pdf
Up till now this has worked fine.
BUT someone transfered a aaa.jpg YET it was not a jpg but a php.
Is there some way to test a file for a pic or pdf other than the extension ?
rubble — 2012-02-10T13:12:00-05:00 — #2
You could try getimagesize() which should fail on anything than an image file.
The problem is you will still need to upload it to use the getimagesize and it would not work with a pdf?
I know jpg files all start with certain characters but I do not know how you could check that: http://en.wikipedia.org/wiki/Magic_number_(programming)
P.S. There is a Unix program to detect file types but I have no idea how you would use it: http://en.wikipedia.org/wiki/File_(command)
john_betong — 2012-02-10T13:27:26-05:00 — #3
patmazuel — 2012-02-12T03:13:51-05:00 — #4
Thanks to all for pointing me in the right direction.
I'll get down to work to try these out.