Assume you have an html form with an input tag of type 'file'. When the file is posted to the server it will be stored locally, along with relevant metadata.
I can think of three ways to determine the mime type:
- Use the mime type supplied in the 'multipart/form-data' payload.
- Use the file name supplied in the 'multipart/form-data' payload and look up the mime type based on the file extension.
- scan the raw file data and use a mime type guessing library.
None of these solutions are perfect.
Which is the most accurate solution?
Is there another, better option?