Click here to Skip to main content
15,915,864 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a requirement to upload only.PDF file, it returns application/pdf mime type.But if I just change the file extension of .txt file to .PDF file then it returns mime type as application/pdf and getting uploaded.Is there any way to check it safely so that some user doesn't just upload unnecessary file.

What I have tried:

I checked the extension and also checked the MIME type of PDF file.
Posted
Updated 26-Jul-17 1:56am

 
Share this answer
 
I could understand that, either we will
1) check the file extension or
2) check the MIME type

I could help with this article though to check the file signatures. Please try. File Signatures[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900