I’ve read through many tutorials and it still isn’t working. I’ve added a sym link but it still doesn’t save or show the image correctly. Can someone tell me the process of the following:
I want to upload an image to the folder storage/app/profilephotos/. It will be called whatever thhe hasname of the image is.
Then I want to be able to view the image via the url on the website.
to test, I created this sym link:
public_path('storage/profilephotos') => storage_path('app/public/profilephotos')
When uploading an image I did this:
Storage::put('profilephotos', $theimagefile);
This uploaded the image to the following directory:
c:myprojectstorageappprofilephotos
The name of the file is for example 12345.jpg.
Now I want to view the iamge on a web apge. In blade I tried to add this but it doesn’t work:
asset('storage/profilephotos/12345.jpg')
I’ve already run storage:link which said:
The [C:myprojectpublicstorage] link has been connected to [C:myprojectstorageapp/public].
I don’t know what else to do, can someone help?
thanks
2
Answers
I think if your code is correct to upload image,then you are using linux based operating system,ubuntu,parrotos,kali-linux etc. may be permission issue, correct the permission of the folder /storage, set min 755.
And also set user of the project folder www-data or at least /storage folder.
Laravel basic code to upload image
Image store at /storage/profilephotos/image_name.png ,you can access image after creating the softlink as
And also first delete the already created softlink in /public folder, create again using command:
Follow above step to upload and view image in laravel.
This May Help..