The doc way is the best and easier way to store and get the file from public
to store $path = $request->file('here name of input of file')->store('file name in public directory');
to get file in view {{asset('$path')}}
How do I upload an image via a form? Answers on stackoverflow tell me that I should use an approach as
$photoName = time().'.'.$request->user_photo->getClientOriginalExtension();
$request->user_photo->move(public_path('avatars'), $photoName);
But after reading the documentation about file storage, I decided to go with the approach
$path = $request->file('avatar')->store('avatars');
This way the path of the image is /avatars
However, when I use asset('storage/'.$user->path) to echo the url in order to display this image within html, my link points to the public directory storage/app/public but the image is stored in storage/app/avatars.
Is the approach I used correct or should I go with the stackoverflow way?
If the approach I used in correct, how do I correctly link the web page to the image?
The doc way is the best and easier way to store and get the file from public
to store $path = $request->file('here name of input of file')->store('file name in public directory');
to get file in view {{asset('$path')}}
Please or to participate in this conversation.