Skip to content

Useful Javascript class that gets the correct Mime Types by file extension.

License

Notifications You must be signed in to change notification settings

rosariogueli/MimeTea.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 

Repository files navigation

MimeTea.js

Get the correct Mime Types by file extension easily using this useful Javascript class.

To use this helper class the only thing you need to do is just submit the file type you want to know the mime type from:
MimeTea.cup("txt");

This will return "text/plain".

You can also submit a file type containing the dot like:
MimeTea.cup(".txt");

If you want to submit an array of file types, MimeTea also supports it:
MimeTea.cup(
    [".txt", ".html", ".css"]
);

Which will return the following Javascript array:
["text/plain", "text/html", "text/css"]

Very useful for application that use the html file input tag where you'll need to specify the accept parameter to contain the correct mime type.

Enjoy. Comments are welcome. Rox

About

Useful Javascript class that gets the correct Mime Types by file extension.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published