//——-curl
$source_file=”example.php”;
$fp = fopen($source_file, “r”);
$url = “ftp://username:password@target_server_url:21 file_path /file_name”;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_UPLOAD, 1);
curl_setopt($ch, CURLOPT_INFILE, $fp);
curl_setopt($ch, CURLOPT_FTPASCII, 1);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($source_file));
$result = curl_exec($ch);
curl_close($ch);
//———
Filed under: Php | Tagged: copy file, curl ftp, transfer file | 1 Comment »