What would you say are the essential steps in verifying a file upload?
I'd tend to check the MIME type, give it a new (random) name, make sure its got an allowed file extension, and then I'd check the contents of the file. How do you go about it?
What would you say are the essential steps in verifying a file upload?
I'd tend to check the MIME type, give it a new (random) name, make sure its got an allowed file extension, and then I'd check the contents of the file. How do you go about it?
What does it mean that the file is "safe"? That it doesn't contain a virus? That you have enough memory to load it?
Also, please add clarifications by editing your original question, not by posting an answer.
Check the file type, check the file size, the image dimension.
These are the 3 I always check to be sure to have good result.
Depends on the expected file contents... might be a good idea to run a virus scan on the file.
Check (in this order): the file MIME type (and note certain browsers have MIME type detection problems...); that the file path exists; that a previous version of the file with the same name doesn't exist, else, rev it; that the file isn't too big; on success, run a virus check on the server.