Getting File Name without Extension
13,469
As an alternative, if you do not want string operations you can use pathinfo()
:
$name = 'file.jpg';
$file_name = pathinfo($name, PATHINFO_FILENAME); // file
$extension = pathinfo($name, PATHINFO_EXTENSION); // jpg
Author by
AngularAngularAngular
Updated on June 26, 2022Comments
-
AngularAngularAngular almost 2 years
Here is my the syntax to get the Uploaded Filename with extension and Getting only the Extension
$name = Input::file('photo')->getClientOriginalName(); $extension = Input::file('photo')->getClientOriginalExtension();
Here if i upload a file named
file.jpg
.Then i will get$name = file.jpg $extension = jpg
Is there any predefined way to get only the file name i.e.,
file
without using any string replace. If not kindly suggest a way to achieve in it str replace or any other way.