0

I have a file uploader module. The UI is created using simple HTML and Javascript. Server side I am using Java code. I want to check the type of the uploaded file.

Puru
  • 8,913
  • 26
  • 70
  • 91

1 Answers1

0

Files don't really have types. The best you can do would be to attempt to load the file as an XLS.

  • If the load succeeds, the file is most likely an XLS.
  • If the load fails, the file is either an invalid/malformed XLS, or not an XLS at all.

You can also look at the uploaded file name or the content type, but neither of these is definitive; i.e. they might say that the file is an XLS when it is something completely different.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216