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"); 
2

1 Answer 1

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/

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.