0
votes

enter image description hereenter image description herei am using hostinger to deploy my laravel project i uploaded all the files into the public_html folder and then did all the necessary changes needed for the application to work.The app seems to work pretty fine but when an user tries to upload a image the image gets stored in the storage/app/public/avatar folder and on public/storage/avatar folder as i have used symlink to link the two folders but yet the photos cannot be viewed by the users. this is how i recall my photo

div class="profile-avatar" style="width: 400px;height:500px; border-radius: 0%;background-image: url('@if(Auth::user()->avatar == "avatar.png") {{ url("/imgs/".Auth::user()->avatar) }} @else {{ url("/storage/avatar/".Auth::user()->avatar) }} @endif');"

please help me to solve this issue

1

1 Answers

2
votes

As you have no ssh access to run some command in shell, try this when uploading the image

1. Store image here: public_path() . 'img/filename.jpg'*

2. Save the 'img/filename.jpg' in database

3. Generate the image URL with url('img/filename.jpg')

// Output http://www.your-domain.com/img/filename.jpg

If you can manage shell access then try this:

Remove your current app/public/avatar directory, which is created inside of storage folder. Also remove your storage folder inside public !

After that via ssh cli, cd to your laravel project folder and create a symbolic link via following command

ln -sr storage public/storage

Hopefully it will solve your issue. I had same issue and mine got fixed via second method ( I had ssh access to my server ).