Posts Learn Components Snippets Categories Tags Tools About

How to get mime type in Laravel 9

Learn how to get a mime type of a file in Laravel 9 the easy way using Storage facade

Created on Apr 16, 2022


In Laravel 9 you can make use of the "mimeType()" method that's available from the "Storage" facade. This method accepts the file path and will return the type as a string.

use Storage;

$mimeType = Storage::mimeType('test.jpg');
Previously in Laravel 8, you can make use "getMimeType()" but since Laravel 9 is using Flysystem 3.0 the method has changed since then.

If you like our tutorial, do make sure to support us by being our Patreon or buy us some coffee ☕️

Load comments for How to get mime type in Laravel 9