I have used Input::file('upfile')->getClientOriginalName()
to retrieve name of uploaded file but gives name with extension like qwe.jpg
.How do I get name without extension like qwe
in laravel.
Laravel uses Symfony UploadedFile
component that will be returned by Input::file()
method.
It hasn't got any method to retrive file name, so you can use php native function pathinfo()
:
pathinfo(Input::file('upfile')->getClientOriginalName(), PATHINFO_FILENAME);
You could try this
$file = Input::file('upfile')->getClientOriginalName(); $filename = pathinfo($file, PATHINFO_FILENAME); $extension = pathinfo($file, PATHINFO_EXTENSION); echo $filename . ' ' . $extension; // 'qwe jpg'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With