What is the correct approach to validating a file upload?
- A Trust the file extension supplied by the browser
- B Verify the real MIME type, cap the size, rename the file and store it outside the web root
- C Only check the file size
- D Rename the file to .php for processing
Answer
Verify the real MIME type, cap the size, rename the file and store it outside the web root
Extensions and the client-supplied type are trivially forged. Storing uploads outside the web root prevents direct execution.





