2

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..

enter image description here

and here is how i am displaying it.. enter image description here

I am uploading the image to the uploads folder under my public folder. and I am storing the image in the database as follows.. enter image description here

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

2 Answers 2

2

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 }}" >
Sign up to request clarification or add additional context in comments.

4 Comments

I would like to upload the images to the public_path of laravel. I can see that the files are getting uploaded but it is not getting displayed on the UI. Hence I think your proposal would not resolve the issue that I am experiencing..
@Gagan, image will upload to the public path.
Yup - works . thanks Anam ... marking this as the correct answer... :)
@Anam please can you help me for this question laracasts.com/discuss/channels/laravel/…
0

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)

1 Comment

sorry - i was using the wrong variable name. Now I have corrected the naming of that variable and posted it again.. thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.