Get The Extension of a File in PHP/Laravel
To get the extension of a file in PHP/Laravel, use the PHP pathinfo()
function. The first argument is the name of the file and the second will be what part of the file to get, which is this case is PATHINFO_EXTENSION
.
$extension = pathinfo($input_file, PATHINFO_EXTENSION);
If there is more than one extension, PATHINFO_EXTENSION
returns the last one.
To get an input file name and then get its extension in Laravel do this:
$input_file = Input::file('image')->getClientOriginalName();
$file_name = pathinfo($input_file, PATHINFO_EXTENSION);
file