Nathan
Nathan

Reputation: 1354

Returning an uploaded file's name

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

Answers (1)

Amit Gupta
Amit Gupta

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 the path, file name, and disk name as its arguments:

Docs

Upvotes: 3

Related Questions