0
votes

Laravel 6.2 application that displays news articles, is showing image, title, and text in a grid.

Images are uploaded in public/images/ folder and accessed using asset('images/image_name.jpg'), image name ar stored in the database.

I have added a new article and uploaded image, everything is the same as was with all other articles.

Now with the last one, there is a problem with displaying image. It shows 404 not found. Now every image I upload on server in this Laravel project public folder I can`t access anymore, shows 404 not found.

  • Tried to clear Laravels cache
  • Uploaded image on a server outside Laravels public folder, then I can access it.

UPDATE

Problem solved, nothing to do with Laravel.

1
Did you run php artisan storage:link? asset is using storage directory, for using it you should run storage:link artisan command and also you should upload images in storages/app/public/images/ - train_fox
I`m using asset and all images now are stored in public/images, all older images I have added ar displaying as it should, last image I have uploaded not displaying. - krismans
Check the image path to the image in the URL store to the database. Also check your env("APP_URL") it is storing the correct URL path. Like for localhost: http://localhost:8080/images/images_name.jpg - Doro
There is lot of articles, every article is working as it should, only for last added there is this problem. I can`t access it via link. I have even copied older article image link and changed to last uploaded image name and it still shows 404. - krismans
Change asset('images/image_name.jpg') to asset('/images/image_name.jpg') add a slash before the path. Hope this helps - sta

1 Answers

0
votes
Route::get('/clear', function() {
    
    $exitCode = Artisan::call('config:cache');
    $exitCode = Artisan::call('config:clear');
    $exitCode = Artisan::call('cache:clear');
    $exitCode = Artisan::call('view:clear');
    $exitCode = Artisan::call('route:clear');
    $exitCode = Artisan::call('clear-compiled');
    return 'DONE'; 
  });