0

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");
dur
  • 15,689
  • 25
  • 79
  • 125
S.P. Soni
  • 39
  • 10
  • where is curl code?? – LF00 May 20 '17 at 07:43
  • 1
    Possible duplicate of [Is there a way to follow redirects with command line cURL](http://stackoverflow.com/questions/18474690/is-there-a-way-to-follow-redirects-with-command-line-curl) – TomTom101 May 20 '17 at 12:30

1 Answers1

1

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/

Renish Khunt
  • 5,620
  • 18
  • 55
  • 92