ralouphie / mimey Goto Github PK
View Code? Open in Web Editor NEWPHP package for converting file extensions to MIME types and vice versa.
License: MIT License
PHP package for converting file extensions to MIME types and vice versa.
License: MIT License
https://mimetype.io/image/heic
Heavily used in Apple iPhones
Now it's easy enough to check if an extension matches a media subtype
$extension = 'mp4';
if ( $mimes->getMimeType($extension) === 'video/mp4' ) {
// ...
}
Would you consider a PR to extend support for asserting media supertypes?
e.g.
$extensions = [
'mp4',
'avi',
'mkv',
];
foreach ( $extensions as $extension ) {
if ( $mimes->isMediaType('video', $extension) ) {
// returns true
}
}
I understand that this is encroaching on the fringes of this lib's scope, but because it's such a standard use case, I was curious if you'd be open to it?
thanks
I tryed:
$extension = $mimes->getExtension('text/x-php');
But return NULL value. Extensions .php are not recognized?
EDIT
I getting mimetype with $file -> getMimeType() on laravel, // text/x-php
At the moment, mimey
best guess the extension of image/jpeg
is jpeg
. I think it's better to change to jpg
as it should be the most common nowaday.
Reference: http://stackoverflow.com/questions/23424399/jpg-vs-jpeg-image-formats
I'm using this class to help to process media files. But when I get the content type of a .mp3 file, it returns audio/mpeg correctly. But when doing the reverse process, it returns .mpga extension instead .mp3, wich doesn't works in iOS.
It occurs because of the order of the extensions in the mime.types file. So I was wondering if this specific order follows any critery or can be changed. If it can, I can make a PR with the changes.
getExtension()
is returning NULL
when mimetype is application/x-gzip
Mime types are content types. A filename does not always describe the content of a file.
I could upload a .php file and name it .jpg - your class here will think its jpeg. Maybe even let me upload it.
You can (and should) use mime_content_type() to test properly... Just letting you know :)
(new \Mimey\MimeTypes())->getMimeType('zip');
'application/zip'
'application/x-gzip'
This wrong mime type means that e.g. Firefox and Chrome handle the file as gzip instead of a zip file and actively renaming the file.
The problem is probably the order in the default configuration:
https://github.com/ralouphie/mimey/blob/develop/mime.types.php#L34
Is there a reason for this order or is this a bug?
Hello! How about php8 support?
My lib has dependency of yours ralouphie/mimey ;)
use Mimey\MimeTypes;
$mimes = new MimeTypes();
$extension = $mimes->getExtension('audio/mp3');
echo $extension;
mp3
null
getExtension()
is returning NULL
when mimetype is image/x-ms-bmp
Please extend for avif images.
Can you add config file to package for add custom mime types for detect extension
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.