I have deployed a Laravel 8 application on my SiteGround website and have been trying to create a symbolic link in the public directory pointing to the storage/app/public directory using php artisan storage:link and I got the error, symlink(): no such file or directory in Filesystem.php. I have scoured the likes of stackoverflow and more for a few days to try and find an answer. The answer I found over and over again was https://stackoverflow.com/a/30198781/16932312 (using the AppServiceProvider.php way if that matters). However, when I changed my public path and printed it out to make sure it is correct I still got the error.
Eventually I decided to change the code that sets up the symbolic link from public_path(storage) => storage_path(app/public)
to the hardcoded directories to see if that would work since the problem was that apparently one of the directories didn't exists. I called php artisan storage:link and lo and behold it worked! A symbolic link was created I didn't get an error!
Unfortunately though something is still not working I don't know if it's because I changed the way the symbolic link is set up or what but when I call Storage::url("imgs/image.jpg")
or asset("storage/imgs/image.jpg")
neither of them find the image. If it is the case on how I set up the symbolic link how do I solve this? Because my public path is pointing to the correct destination. It worked just fine right before I deployed it so I just don't know what could have caused it to stop working. Any help would be appreciated!
I don't know if these will help much but I printed out some values to check things:
<p>1) {{ public_path() }}</p>
<p>2) {{ storage_path() }}</p>
<p>3) {{ file_exists(public_path("storage")) }}</p>
<p>4) {{ file_exists(public_path("storage/imgs")) }}</p>
<p>5) {{ file_exists(public_path("storage/imgs/test.jpg")) }}</p>
<p>6) {{ file_exists(Storage::url("imgs/test.jpg")) }}</p>
<p>7) {{ file_exists(public_path("test")) }}</p>
<p>8) <img src="public_path('storage/imgs/test.jpg')" alt="Test"></p>
Both 1 and 2 print out the correct paths. 3, 4, and 5 print out 1. 6 and 7 print out nothing. Finally 8 just shows the alt with no image which I find strange because apparently that file exists.
Edit: I was just looking at it a little more and using Storage::url("imgs/test.jpg")
or asset("storage/imgs/test.jpg")
is actually giving me a 403 error when I'm trying to access it it looks like.