Preserve uploaded file names in Laravel
•
1 min read
In a lot of scenarios, I want to maintain the name of a file when a user uploads it to a site, rather than using a randomnly generated one.
I sometimes forget the methods I need to call to make this work though, so here is a little code snippet for future me and anyone else who happens to come across this on the internet.
$request->file('upload')->storeAs('uploads', $request->file('upload')->getClientOriginalName())