image is not showing in index page from admin panel
hi m trying to show products from admin panel to index page, when i add product(its image and its details) then this is showing in admin view products but only details are showing in index.blade.php, or image is not showing:
@foreach($productsALL as $product)
<img src="{{ asset('images/backend_images/products/small/'.$product->image) }}"
alt="IMG-PRODUCT">
@endforeach
I believe that the problem is because of missing / at the beginning of the URL, so I assume that your images folder is within the public directory, then just changing it with this:
will do the work. Because when you are on the index page, it uses the correct path, but when you are on different page, for example yourdomain.com/products it will try to find the image in products/images ... instead of just yourdomain.com/images. Hope this helps.
@AAAA1111 - Can you please check in your browser, inspect the image element and make sure that the url is correct and the picture can be found on that location. Or share the exact error that you are getting here.
@NAKOV - in inspect element in console it says: Failed to load resource: the server responded with a status of 404 (Not Found)
and m getting only product details like price and name not image just default image sign
@AAAA1111 - Does the store method works for you? Can you look in your project public/images/... directory and make sure that when you upload an image the image can be found there? The error says 404 because the image cannot be found, so you need to make sure that you use the correct URL. I assume that the error shows in which location it tries to find the image, so based on that you should check your public folder.
@AAAA1111 - sorry, but not having your code to test locally I can't help you much more than what I've already said. I am 100% sure that it is something with the URL used, so inspecting the image element in the index page, and looking at the src after the page has been loaded should give you more info on where to look at. Or just try to use url() helper function instead of the asset() and see if that helps.