A) upload the file at the url:
$destination = fopen("tmp/myfile.ext","w"); //Myfile.ext is an example you should probably define the filename with the url. $source = fopen($url,"r"); while (!feof($source)) { fwrite($destination,fread($source, 8192)); } fclose($source); fclose($destination);
B) Upload the file to FTP:
$file = 'tmp/myfile.ext'; $fp = fopen($file, 'r'); $conn_id = ftp_connect($ftp_server); $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); if (ftp_fput($conn_id, $file, $fp, FTP_ASCII)) { echo "UPLOAD OK"; } else { echo "ERROR"; } ftp_close($conn_id); fclose($fp);
This is just a quick example, perhaps many improvements that can be made to this code, but the basic idea is here.
Note. If you have a dedicated server, it may be faster and easier to download a file with a wget call.
More information on FTP can be found in the document.
grunk source share