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 from checking the previous extensions or if possible by checking the file content. Is there any way for that?
Asked
Active
Viewed 548 times
0
-
Possible duplicate of [Getting A File's Mime Type In Java](https://stackoverflow.com/questions/51438/getting-a-files-mime-type-in-java) – tima Jul 25 '17 at 20:40
-
you can also use something like Apache Tika: https://tika.apache.org/ if you are not opposed to third party libraries. – tima Jul 25 '17 at 20:41
-
@tima can i use this with pluploader – reenu jose Jul 25 '17 at 20:44
-
I've never used Puploader, so I'm not sure. – tima Jul 25 '17 at 20:45
-
I'm not sure if you're able to do that on the client-side, since you don't process the file on the javascript. It's better that you perform a simple validation on the client side and on the backend verify the type of file. – Luís Cruz Jul 30 '17 at 12:09
-
@milz But how can it possible from client side. Is there any way. I only got the current filetype. I need the original one. – reenu jose Aug 02 '17 at 01:42