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);
Top comments (0)