dimanche 18 août 2019

How to display an storage image Laravel 5.2

I want tho disply an image on my view, but i receive File not found

The two erros: FileNotFoundException in FilesystemAdapter.php line 61: storage/app/public/covers/teste-bravo_cover.jpg

FileNotFoundException in Filesystem.php line 386: File not found at path: storage/app/public/covers/teste-bravo_cover.jpg

But the image are on the correct folder:

a busy cat fileOnFolder

Well, in Laravel 5.2 storage:link won't work

Image store on disk -works fine to store the image

if($cover){
            dump("ok1");
            Storage::disk('public_covers')->put($covername, File::get($cover));

            $coverObject = New Cover();      

            //path com o nome do arquivo
            $coverObject->imagePath = 'storage/app/public/covers/'.$covername;
            dump($coverObject->imagePath);
        }

        //Salva a capa com o path para o arquivo
        $coverObject->save();

My filesystems (with the "public_covers" disk) -works fine to store the image

        'public_covers' => [
            'driver' => 'local',
            'root' => storage_path('app/public/covers'),
            'visibility' => 'public',
        ],

View code: (if movie have cover, show them)

                @if($movie->cover)
                <img src="" />
                @endif

Route code, directing to controller method

Route::get('/movieimage/{coverId}',
[
               'as' => 'cover.image',
               'uses' => 'MovieController@getimage'
           ]
);

Controller Method to take the image

    public function getimage($coverId){
        $movie = Cover::find($coverId);
        //dump($movie);
        $imagePath = $movie['imagePath'];

        dump($imagePath);

        $file = Storage::disk('public_covers')->get($imagePath);

        $response = Response::make($file, 200);
        return $response;     
    }



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2YZbGKD
via IFTTT

Aucun commentaire:

Enregistrer un commentaire