简体   繁体   中英

Image show URL does not work in Laravel 5

I am new to Laravel 5, so I have no huge experience in Laravel. I am learning. I have been faced a very critical problem: I upload the image and save the database and my public directory image folder.

And finally I show this image my home page like localhost/image_upload/public/ but when I show this localhost/image_upload/public/image/show URL the image not load but everything is working fine.

Route:

//it is work
Route::get('/','SliderController@show');

//it's work
Route::get('/image/show','SliderController@show');

controller:

public function show(){

    $images = SliderModel::all();

    return view('index',compact('images'));

Method 1 :

You shall show your images by

{{ HTML::image("public/yourimage.png", "Logo") }}

Method 2 :

As you are passing the Slider images from controller,

$images = SliderModel::all();
#Here you are getting all the images from SliderModel, 

You shall do this in your view

Step 1 : Do a foreach

@foreach ($users as $user)
{{ HTML::image($user->images, "Logo") }}
@endforeach

Note :

I consider that images is the field that you used to store the images path in side SliderModel Model (Table refers it)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM