Posts Learn Components Snippets Categories Tags Tools About

How to get mime type from storage class in Laravel

Learn how to get mime type and file size in bytes easily using Laravel storage class

Created on Jan 25, 2022


To get the file size in bytes and the mime type/extension type from the Storage class you can define your code like below. Do note that we are accessing the "public" disk but it can be any of your specified disks such as "s3" or "digital ocean space".

// get size in bytes

// get mime type
The "size" will return the "size" in bytes e.g 16000 bytes.
While the "getMimeType" will return the type of the file e.g "image/jpeg"

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


PostSrc Code Components

Collection of Tailwind CSS components for everyone to use. Browse all of the components that are right for your project.

View Components

Sponsors 👑

+ Add Yours