Get Filename Without Extension in PHP/Laravel

To get the full name of a file without its extension in PHP use the pathinfo() function. Pass the file name as the first argument and PATHINFO_FILENAME as the second.


$file_name = pathinfo($input_file, PATHINFO_FILENAME);


In Laravel you can get the name of an uploaded file using the getClientOriginalName() method. The full example of getting the full name of a file without the extension is:


$input_file = Input::file('image')->getClientOriginalName();

$file_name = pathinfo($input_file, PATHINFO_FILENAME);