Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get file name without extension in laravel?

Tags:

php

laravel

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.

like image 578
Sumit Avatar asked Nov 18 '15 09:11

Sumit


2 Answers

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); 
like image 138
Maxim Lanin Avatar answered Oct 04 '22 19:10

Maxim Lanin


You could try this

$file = Input::file('upfile')->getClientOriginalName();  $filename = pathinfo($file, PATHINFO_FILENAME); $extension = pathinfo($file, PATHINFO_EXTENSION);  echo $filename . ' ' . $extension; // 'qwe jpg' 
like image 27
Pantelis Peslis Avatar answered Oct 04 '22 17:10

Pantelis Peslis