Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
March 25, 2022 06:51 pm GMT

How to get file extension from path in Laravel 9?

we will write simply get pathinfo(). how to get file extension from path in laravel. extension is here the define pathinfo(). location of your image to uplaod in your laravel code.

we will use pathinfo(). and PATHINFO_EXTENSION use this extension word after get this extension confortable.

AND WE WILL use this code get extension. laravel framwork

Example 1 how to get file extension from path in laravel?

$_GETEXTENSTION = pathinfo(storage_path('/uploads/image.png'), PATHINFO_EXTENSION);
dd($_GETEXTENSTION);

Example 2:

`$_PATH_INFO = pathinfo(public_path('/uploads/image.png'));

$_EXTENSTION = $_PATH_INFO['extension'];

dd($_EXTENSTION );`

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

`$_EXTENSTION = $request->file->extension();

dd($_EXTENSTION);`

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

$_EXTENSTION = $request->file->getClientOriginalExtension();
dd($_EXTENSTION);


Original Link: https://dev.to/dev_laravel1/how-to-get-file-extension-from-path-in-laravel-9-31b1

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To