CURL simulates FTP downloading files

Source: Internet
Author: User
Tags ftp file ftp login
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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.