CURL simulates FTP file upload & lt ;? PhpCURL simulates FTP file upload & nbsp; author: mQQ: 251171960 $ url & quot; ftp: Large & quot; CURL simulates FTP file Upload
// CURL simulates FTP file Upload
// Author: m
// QQ: 251171960
$ Url = "ftp: // 61.54.28.3/". mt_rand (99,999). ". txt ";
$ File = "20090829.txt ";
$ Fp = fopen ($ file, "r ");
$ Ch = curl_init ();
Curl_setopt ($ ch, CURLOPT_VERBOSE, 1); // report an accident
Curl_setopt ($ ch, CURLOPT_USERPWD, 'ffff: ***** '); // FTP login account password, simulated login
Curl_setopt ($ ch, CURLOPT_URL, $ url );
Curl_setopt ($ ch, CURLOPT_PUT, 1); // upload a file over HTTP
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); // no output
Curl_setopt ($ ch, CURLOPT_INFILE, $ fp); // the object to be uploaded
Curl_setopt ($ ch, CURLOPT_INFILESIZE, filesize ($ localfile); // upload file size
$ Http_result = curl_exec ($ ch); // execute
$ Error = curl_error ($ ch );
Curl_close ($ ch );
Fclose ($ fp );
If (! $ Error)
{
Print "successful ";
}
?>
------ Solution --------------------
Thank you for taking a look!