Reputation: 1354
Laravel automatically renames an uploaded file. How do I know (make it return) the uploaded file's new name? Is there any function that does this?
Upvotes: 1
Views: 52
Reputation: 17658
You can try storeAs()
function as:
$filename = 'filename.jpg';
$path = $request->photo->storeAs('images', $filename);
retrun $filename;
From the docs
If you do not want a file name to be automatically generated, you may use the
storeAs
method, which accepts thepath
,file name
, anddisk name
as its arguments:
Upvotes: 3