this is how i have written my code in the show.blade.php file
<img class="img-responsive thumbnail" src="{{ Storage::disk('public')->url('post/'.$post->image) }}">
Any mistake? plaese help
I have uploaded image successfully into my storage/post folder with Image Intervention and i have link the storage with public folder with this upload code
public function store(Request $request)
{
$this->validate($request,[
'title' => 'required',
'image' => 'required',
'categories' => 'required',
'tags' => 'required',
'body' => 'required',
]);
$image = $request->file('image');
$slug = Str::slug($request->title);
if(isset($image)){
$currentDate = Carbon::now()->toDateString();
$imageName = $slug.'-'.$currentDate.'-'.uniqid().'.'.$image->getClientOriginalExtension();
if(!Storage::disk('public')->exists('post')){
Storage::disk('public')->makeDirectory('post');
}
$postImage = Image::make($image)->resize(1600,1066)->stream();
Storage::disk('public')->put('post/'.$imageName,$postImage);
}else{
$imageName = "default.png";
}
$post = New Post();
$post->user_id = Auth::id();
$post->title = $request->title;
$post->slug = $slug;
$post->image = $imageName;
$post->body = $request->body;
if(isset($request->status)){
$post->status = true;
}else{
$post->status = false;
}
$post->is_approved = true;
$post->save();
$post->categories()->attach($request->categories);
$post->tags()->attach($request->tags);
LaraFlash::success('Post has been added successfully');
return redirect()->route('admin.post.index');
}
But when i want to show the image, the image is not show and i have check the image url which is
<img class="img-responsive thumbnail" src="http://localhost/storage/post/like-this-2019-11-28-5de04b6d758ac.jpg">
and my .env url is
APP_URL=http://localhost
Or am i missing any thing? please help
@alewa and you've tried using the asset() helper?
<img class="img-responsive thumbnail" src="{{ asset('storage/post/'.$post->image) }}">
Make sure that you see in your public folder storage/app/post/ the image here.
Please or to participate in this conversation.