How to access an image that was to uploads my laravel folder through FIleUpload

0

I have a form that makes uploads of images, when I upload, the path is saved in the bank by the path field, I recover that image and set it in a array image

this.image = data;

Now how can I display this image in a HTML using the image.path ??

<img src="{{ image.path }}">

I tried this and it did not work

Image controller code

$filename = $file->store("uploads/{$idCampaign}/images");
                if (!$agency) { throw new NotFoundHttpException('agency_not_found'); }
                if ($filename) {
                    $image->file_extension = $file->getClientOriginalExtension();
                    $image->filename = $file->getClientOriginalName();
                    $image->path = $filename;
                    $result = $this->service->save($image);

                    $img = new ImageCampaign();
                    $img->setCampaign($campaign);
                    $img->setImage($image);
                    $img->setAgency($agency);
                    $img->fill($request->post());


                    $this->imageCampaignService->save($img);

                    DB::commit();
                    return response()->json($result);

This code inserts the image into the bank

    
asked by anonymous 11.01.2018 / 15:53

1 answer

0

Take a look at the official documentation: link

But when you upload it, it throws the file in the storage folder, but only the public folder is publicly visible, so what Laravel says is to create a public / storage folder and create a symbolic link with the storage folder / app / public. In this way files that are placed in the storage / app / public can be seen publicly.

To display is easy:

<img src="{{asset('storage/'.$image_name}}">
    
11.01.2018 / 16:24