How can I download several images in laravel 5.5

0

Hello good day I would like to know if it is possible to download images of laravel with respect to information in the BD, For example I want only images of a number of users that they themselves raised, in a result they take 60 or more that can download the images of those users with that score. Until now I have researched this

(this code was taken from a blog but it gave me a certain idea)

This would put it in view

<li><a href="{{url('user/download')}}">Descargar términos y condiciones de uso</a></li>

This in my route file

Route::get('user/download', 'UserController@download');

This would be the method

protected function downloadFile($src){ if(is_file($src)){ $finfo = finfo_open(FILEINFO_MIME_TYPE); $content_type = finfo_file($finfo, $src); finfo_close($finfo); $file_name = basename($src).PHP_EOL; $size = filesize($src); header("Content-Type: $content_type"); header("Content-Disposition: attachment; filename=$file_name"); header("Content-Transfer-Encoding: binary"); header("Content-Length: $size"); readfile($src); return true; } else{ return false; } }

and in this way I would call the method

public function download(){ if(!$this->downloadFile(app_path()."/files/terminos.pdf")){ return redirect()->back(); } }

The thing is, how can I implement something like that but for certain users already mentioned above?

    
asked by Dohko19 24.10.2018 в 06:12
source

0 answers