Search code examples
htmlfile-extension

how to find out the file format for .eml file to be used for accept attribute in input type="file"?


I am using a file input html element for file upload.

<input type="file" name="data[File][0][attachment]" accept="application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/pdf"style="display:inline;width:70%% !important;" class="file-upload" />

I know that for:

  • pdf is application/pdf
  • MS word is application/vnd.openxmlformats-officedocument.wordprocessingml.document

I need to add .eml into the accept attribute as well

How do I find out for .eml file type?

I tried application/eml it didn't work.


Solution

  • Looks like .eml files have no mime type. It's not listed here http://www.iana.org/assignments/media-types/media-types.xhtml.

    But since the accept attribute accept both mime types and file extensions, you can add .eml to it's value. Try this

    <input type="file" name="data[File][0][attachment]" accept="application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/pdf,.eml"style="display:inline;width:70%% !important;" class="file-upload" />