Click here to Skip to main content
15,890,345 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am using Puploader to upload file in a java project. I am restricting some of the filetypes like .exe from uploading. But when the extension is changed it gets uploaded. For example, when a user changed the extension of the test.exe file to test.txt and tried to upload, its get uploaded in the project. This cause serious issue in my project as the file is downloadable by other users.
So I need to restrict the files by checking the previous extensions or if possible by checking the file content. Is there any way for that?
If not possible by using Plupload, please suggest a way to do it in javascript.

What I have tried:

Now, I fetch the extension from the filename using substring in javascript. I need a way to find out the original filetype even if the extension has changed.
Posted
Updated 26-Jul-17 9:46am

1 solution

No, there isn't.
The file extension is what gives the file it's "type", there is no other "signature"to a file which gives this information. And the file extension is part of the file name and can be changed at will; previous file names (including extension changes) are not stored anywhere and cannot be retrieved once the name is changed.
 
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