Page 1 of 1
File validation with Php
Posted: Wed May 09, 2007 4:42 pm
by user___
Hi guys,
I have an upload form which accepts file which are the following types:
.exe,.swf,.avi.wmv.pdf.mpg, and mpeg
Is there any possible way to check whether these file types are real or not.
Thanks.
Re: File validation with Php
Posted: Wed May 09, 2007 4:48 pm
by Chris Corbyn
user___ wrote:Hi guys,
I have an upload form which accepts file which are the following types:
.exe,.swf,.avi.wmv.pdf.mpg, and mpeg
Is there any possible way to check whether these file types are real or not.
Thanks.
Reading the file extensions is a big no-no, but you sounds like you figured that
The .exe one will be tricky since that could probably be anything at all.
For the others, you can usually check the first few bytes in the file to see if they match the required headers. I'm not 100% though.
Reply
Posted: Wed May 09, 2007 5:05 pm
by user___
Actually, I did not figure it. I totally agree about the .exe file and it is already dropped from my list. Now, I would like to ask you whether you know how this header validation can be done.
Any kind of information is highly appreciated.
Posted: Wed May 09, 2007 5:31 pm
by volka