Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 28, 2010 05:50 PM by amalhashim
Feb 28, 2010 03:57 PM|LINK
I'm doing a project in component management system. I need to block executable files from getting uploaded. Blocking should not be based on the extensions. For example, i've a file named abc.exe i'm going to change the file extension to abc.jpg in this case
that abc file should not get updated. Similar to that in gmail file attachment. Someone plz help me with this one..
Feb 28, 2010 05:50 PM|LINK
For doing this you can use the Magic numbers of the file. For each file type, there will be a pre-defined byte pattern.
Using this pattern is the way Operating system is finding the file type.
What you need to do is, read the initial few bytes of the file thats been trying to upload, compare the bytes
and make sure it don't have the byte pattern of an executable.
One thing i need to point out here is, you will be uploading the file. But based on the comparison you can either reject the
remaining data and throw an error.
Hope this helps.