I need a snippet to check file for validity (I’m allowing users to upload xml files). So I need to check whether uploaded file is XML.
The best I can think of is just check if extension is “.xml”. What if its replaced?
I need a snippet to check file for validity (I’m allowing users to upload
Share
You can try loading it like this and catch the exception: