Problems obtaining an image from the public folder in a route. Laravel.

0

In one of the tables that you create from the database there is a field of type file.
The file (image) is stored correctly in the database. As follows:

    if($request->file('imagen')){  //condicion de si existe la peticion                             
 $publicacion->imagen=Storage::disk('public')->put('image',$request->file('imagen'));                                                                                 
$publicacion->fill(['file'=>asset($publicacion->imagen)])->save(); //almacena la imagen la carpeta public en una carpeta nueva llamada image. 
   }

Function in the controller to call the data of the database and show in a view:  public function article ($ id)     {

    $publicaciones=Publicacione::where('id',$id)->get();

    return view('articulo')->with('publicaciones',$publicaciones); //la vista se llama articulo y la ruta articulos. 
}

View:

<img  src="{{$publicacione->imagen}}" alt="">

The image is not displayed, when inspecting the source code the image path is displayed:

image / 7kReFxMpxgucU3Vac5hVqCqdUFRcgtMcQ7sJ3v3T.png but when you click, the following route opens:

link

PS: The problem I think is generated is by the prefix article of the route, but I do not know how to proceed.

    
asked by Angel Gomez 06.05.2018 в 03:15
source

1 answer

0

try with

<img  src="{{url('/'.$publicacione->imagen)}}" alt="">

or

{{ HTML::image($publicacione->imagen, 'alt text', array('class' => 'css-class')) }}
    
answered by 06.05.2018 / 04:20
source