I have stored my image with following code
if (isset($image)) {
// make unique name for image
$currentDate = Carbon::now()->toDateString();
$imagename = $slug . '-' . $currentDate . '-' . uniqid() . '.' . $image->getClientOriginalExtension();
// check category dir is exists
if (!Storage::disk('public')->exists('category')) {
Storage::disk('public')->makeDirectory('category');
}
// resize image for category and upload
$category = Image::make($image)->resize(1600,479)->stream();
Storage::disk('public')->put('category/'.$imagename,$category);
// check category slider dir is exists
if (!Storage::disk('public')->exists('category/slider')) {
Storage::disk('public')->makeDirectory('category/slider');
}
// resize image for category slider and upload
$slider = Image::make($image)->resize(500,333)->stream();
Storage::disk('public')->put('category/slider/'.$imagename,$slider);
} else {
$imagename = "default.png";
}
try with this code
<img src="images/icons8-team-355979.jpg" alt="Profile Image">
Failed to load resource: the server responded with a status of 404 (Not Found) this is the error
Try this
<img src="{{url('category/slider')}}/{{ $category->image }}" alt="{{$category->name}}">
The url function will go to '/public' folder. So, you may need to edit your '/config/filesystem.php' so that the uploaded photo is saved inside the '/public' directory.
For more information on this please check this document .
When you want to serve files from the public disk directly, you need to create a symlink to these files. This is described in the documentation here: https://laravel.com/docs/5.7/filesystem#the-public-disk .
When you have done this, you can link to the assets using the asset()
function.
echo asset('category/slider/icons8-team-355979.jpg');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.