How to get file extension from path in Laravel?

How to get file extension from path in Laravel?

In this post we will give you information about How to get file extension from path in Laravel?. Hear we will give you detail about How to get file extension from path in Laravel?And how to use it also give you demo for it if it is necessary.

You can simply use pathinfo() for get file extension from string in php laravel. we might some time require to get file extension from location of file or image.

Here will show you simply way to get file extension from storage path or public path. we will use pathinfo() of code php.

we will use pathinfo() with PATHINFO_EXTENSION parameter to getting image extension in php laravel framework.

Example 1:

$extension = pathinfo(storage_path('/uploads/my_image.jpg'), PATHINFO_EXTENSION);

dd($extension);

Example 2:

$infoPath = pathinfo(public_path('/uploads/my_image.jpg'));

$extension = $infoPath['extension'];

dd($extension);

If you have file object from request then you can simply get by laravel function.

Also see:Laravel 5.7 Import Export Excel to database Example

$extension = $request->file->getClientOriginalExtension();

dd($extension);

I hope it can help you…

Hope this code and post will helped you for implement How to get file extension from path in Laravel?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

63  +    =  73

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US