Laravel image not found in public/storage
P粉043566314
2023-08-26 20:51:28
<p>I'm trying to access images for my project. </p>
<p>I have run php artisan storage link</p>
<p>Laravel Create Public/Storage</p>
<p>When I upload an image to storage/app, I see the image in storage/app but not in public/storage. </p>
<p>When I try to view the image on my browser, I get an error 404</p>
<p>controller.php</p>
<pre class="brush:php;toolbar:false;">Property::create([
'SittingRoom'=> request()->file('sittingroom')->store('apartments')
]);</pre>
<p>bladeview.php</p>
<pre class="brush:php;toolbar:false;"><img src="{{asset('storage/'.$duplex->SittingRoom)}}"></pre>
<p>Browser link</p>
<pre class="brush:php;toolbar:false;">http://127.0.0.1:8000/storage/apartments/HNLDysVUdRG7ZTBkF2qFGk2B2tAKYzYcVImNEWLx.jpg</pre>
<p>After running artisan storage link</p>
<p>C:xampphtdocsOPAAM> php artisan storage: link</p>
<p>Message [C:xampphtdocsOPAAMpublicstorage] link is connected to [C:xampphtdocsOPAAMstorageapp/public]. </p>
The problem isconfig/filesystems.php
But in the .env file
This configuration will save your images in
Storage/app
instead ofstorage/app/public
.Images saved in
storage/app
are not publicly accessible. So you have to change the .env file