Simple file downloading with php


#remote file to open
$ch = curl_init("http://www.example.com/test.zip");
#where to save the file
$fp = fopen("test.zip", "w");
#curl options for downloading and saving the file.
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
#complete the curl task
curl_exec($ch);

curl_close($ch);
fclose($fp);

This allowed me to download a file “test.zip” and save it to my web server.

similar to the below script

Leave a Reply

Your email address will not be published. Required fields are marked *