Php – Laravel 5.4 Showing 404 Not Found (Public Storage)

laravelPHP

I have a question regarding to public storage and storage itself

After i done inserting the files to the storage.
then in the views page i want to display the files that i store to the storage.
but i got problem i got error.

Failed to load resource: the server responded with a status of 404 (Not Found)

  • I've run php artisan storage:link
  • The image exists in the public storage folder

Image Exist in the public storage folder & I've run the php artisan storage link

This is my code, how can i insert the file to storage.

$filename =  $request->file->getClientOriginalName();
$request->file->storeAs('storage',$filename); 

This is my code, how to display the image to the view page

@foreach($home_slider as $get_data_slider)
   @if($get_data_slider->slider_sorting == '1')
                
      <a href="{{$get_data_slider->link}}" target="_blank"><img src="{{ asset('/public/storage/'.$get_data_slider->file.'') }}" class="d-block w-100"></a>
                
    @endif
@endforeach

I found out that i can't access the localhost:8000/public/storage/1.jpg

404 not found

But when i use the localhost:8000/storage/1.jpg the file is showing.
Showing image when the url is without public

Thanks..

Best Answer

I had to run php artisan storage:link from the vagrant box to get the symlink to actually take effect.

Related Topic