March 25, 2022 06:51 pm GMT
Original Link: https://dev.to/dev_laravel1/how-to-get-file-extension-from-path-in-laravel-9-31b1
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:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To