I have my website in http://domain1.com
and I want to download some .zip
file from another domain http://domain2.com/uploads/data.zip
but not getting download and showing 302 moved temporary error. I am using cURL code.
header('Access-Control-Allow-Origin: http://www.domain2.com');
header('Content-Length: '.filesize($response));
header('Content-Type: application/zip');
header('Content-Transfer-Encoding: Binary');
header("Content-Disposition: attachment; filename=my.zip");
//readfile($response);
header("Location:$response");
Just create one php file on project root. like "test.php"
now add below code on "test.php" file.
file_put_contents("zipname.zip", fopen("http://domain2.com/uploads/data.zip", 'r'));
This is fastest and easy way to download file using php.
for more detail below article
https://thecodingstuff.com/php-download-archive-file-from-url/