Download zip file in laravel

1.8k views Asked by At

When my user clicks 'Download app', the zip file downloads to his/her computer. I want it so that when my user clicks 'Download app', the zip file saves to my server (linux). enter link description here

1

There are 1 answers

5
Khan Shahrukh On

There are three things

  1. Download file to your server from some online resource
  2. Download file to client's computer from your server
  3. Upload from client's computer to your server

And as far as I can understand you want the first one, so for that you may get the file with file_get_contents. You may also use curl for that the following is an example with file_get_contents();

$file = file_get_contents('url_provided_by_the_user');
$destinationPath = public_path() . '/location/to/save/'.$filename . '.extension';
file_put_contents($destinationPath, $file);
}

if by any chance I got confused to understand your question please comment below and I will try to rectify things