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.
A:
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
2010-06-21 04:26:16
I think you mean "XLS" (as in Excel's file format) =)
Mark E
2010-06-21 04:28:25
Yup ... good catch.
Stephen C
2010-06-21 04:33:34