4

I am making a web page on laravel 5, I haven't used laravel since it was at 3 but I really like the new features that it has.

Everything its working fine on an app that it's almost finished, but I have a problem with images.

I am trying to display an image to a view and it's just not showing, I get the little image icon that we all know.

I have used all the methods that I have found on larval docks and in the forums. including:

  • assets
  • URL
  • HTML (It didn0t work at all)
  • Direct Url in the view

I am actually using just Artsian serve so the URL would be something like:

http://localhost:8000/uploads/images/posts/1456814127.jpg

The folder its un public folder so in my opinion its the correct url. With diffrent methos i aslo called the image from the pc path and its the same result. I am using intervention to upload the image by the way.

Any idea?

EDIT:

Ok i tried on localhost of wamp server and the image output worked. I dont know why but it did.

EDIT 2: I am on laravel Homestead now, and it's still not working. I am angry by this point. Please help me!!

Here it's my Controller:

public function posts()
{
    $posts = DB::table('posts')->paginate(3);
    //page heading
    $title = 'Latest Posts';

    return view('frontend.posts.index')->with(compact('posts', 'title'));
}

This it's my view:

<a href="#" class="image">
  <img src="{{ asset('uploads/images/posts/'.$post->post_image) }}" class="img-rounded">
  <span class="hover-zoom"></span>
</a>

At laravel homestead the output link it's: http://krubbit.dev/uploads/images/posts/1457074877.jpg

The dir structure of the image location:

-Laravel-dir
  -Public
   -Uploads
     -images
       -posts
         -1457074877.jpg
Krubbit
  • 41
  • 2
  • 7

2 Answers2

0

Something like this

<img src="{{ asset('uploads/images/posts/1456814127.jpg') }}" />
Drudge Rajen
  • 7,584
  • 4
  • 23
  • 43
  • Same result. it also gives me the same image link. – Krubbit Mar 02 '16 at 06:07
  • I am just trying new options and i passed the exact same directory to the Wamp www folder and tried it at the Wamp localhost and work just fine. So the problem its with the Serve command in the laravel app. I really work just fine With artisan serve. Any idea of why its not showing images. – Krubbit Mar 02 '16 at 06:08
  • do you mean it doesn't show image when you run php artisan serve ?? – Drudge Rajen Mar 02 '16 at 06:10
  • When i see the page with the URL that artisan serve gives me its not showing the image. When i see the page with the URL that WAMP gives me y cCAN see the image. – Krubbit Mar 02 '16 at 06:25
0

Please use url funcion of Laravel as shown below

<a href="#" class="image">
  <img src="{{url('asset/uploads/images/posts/'.$post->post_image)}}" class="img-rounded">
  <span class="hover-zoom"></span>
</a>

Hope this will help..!!

Deepak Raj
  • 31
  • 3