To download file to your server from external server where you have difficulty to have ssh enabled. So below is the curl code you can use for download.

$url = ‘Your Download URL’;
$fp = fopen (dirname(__FILE__) . ‘/localfile.tmp’, ‘w+’);//This is the file where we save the information
$ch = curl_init(str_replace(” “,”%20”,$url));//Here is the file we are downloading, replace spaces with %20
curl_setopt($ch, CURLOPT_TIMEOUT, 50);
curl_setopt($ch, CURLOPT_FILE, $fp); // write curl response to file
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_exec($ch); // get curl response

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.