Reputation: 5656
I have a blog post application where I am uploading files to be displayed along with the post itself. I can successfully upload the image but I am unable to display it .
Here is how I am uploading it to a folder within my application..
and here is how i am displaying it..
I am uploading the image to the uploads folder under my public folder. and I am storing the image in the database as follows..
Although I can see that the image path is correct. I did an echo of the path that is being generated and the path to the image is correct.
Can you please let me know if there is something that I am doing wrong.
thanks
Upvotes: 2
Views: 4255
Reputation: 12169
Change
$file = $file->move(public_path() . '/images/uploads', $filename);
to
$file = $file->move('images/uploads', $filename);
the above code will upload the picture to the public_path/images/uploads
.
In your code, i can see you have used full physical path of your image directory to display the picture. Physical path only needed when you are going to upload an image.
try the following:
<img class="img-responsive" src="/images/uploads/{{ $post->thumbnail }}" >
Upvotes: 2
Reputation: 3
You are storing the thumbnail within the post model, but are trying to fetch it form the blog model. Try $blog->post->thumbnail instead. (If you have set a relationship)
Upvotes: 0