php - Laravel get File object from absolute path -


how can file object absolute path?

the object when $request->file('fileinput').

so can use method $file->getclientoriginalname() or $file->getclientoriginalextension() or that.

i can find way file object using file::allfiles($absolutefolderpath) , loop through find file have filename looking for.

but there simpler?

request::file() method returns objects of class uploadedfile. can create such object yourself, kind of kills purpose of class, it's supposed used for, well, uploaded files :) should use file class instead parent class of uploadedfile. can create such object way:

$uploadedfile = new \symfony\component\httpfoundation\file\file($filepath); 

if instantiate file way, won't have access getclient...() methods used return information file got client browser.

if want additional info file can use getmimetype() or getextension() methods.


Comments