Answer the question
In order to leave comments, you need to log in
Original name when uploading a file?
This is how I upload the file to the server,
if($request->hasFile('img')) {
$file = $request->file('img')->store('uploads', 'public');
}
jLyiDxpJWkhiImPOBVwNo6yd3HQciCKTAPLIWsAv.jpegTell me how to return the normal file name,
Answer the question
In order to leave comments, you need to log in
This is a valid file name that excludes duplicates within the same directory so that the contents of the file are not overwritten. If you wish, you can read the laravel documentation, which tells how to work with the methods of this class.
If you still want to save the file with the original name, there is also a solution below. You can pass a second parameter to the storeAs method with the file name.
$path = $request->file('avatar')->storeAs(
'avatars', $request->user()->id
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question