How to create a file (name_of_file . file_extension), by mime type? The list of mimes is dynamic.
Example:
MIME Extension
application/msword | .doc
text/plain | .txt
text/css | .css
I dont wanna use array(“mime” => “extension”);
I have the mime type, but i need the file extension.
To avoid using a lookup table (at least avoid you having to define one) you can use
finfo_file.If you’re on 5.0, you may try
mime_content_type(But keep in mind this is deprecated, so if you’re looking for upgrade-compatible, you may want to default to the newfinfo_filewhen possible):