Php method for FTP transfer of files based on Curl

Source: Internet
Author: User
Tags ftp file ftp file transfer ftp transfer
This article mainly introduces PHP based on the implementation of the FTP file transfer files, interested in the friend's reference, I hope to be helpful to everyone.

Specific as follows:

<?phpfunction upload ($dir, $src, $dest) {  $ch = Curl_init ();  $fp = fopen ($src, ' R ');  curl_setopt ($ch, Curlopt_url, ' ftp://user:pwd@host/interpretation/'. $dir. ' /'. $dest);  curl_setopt ($ch, curlopt_upload, 1);  curl_setopt ($ch, Curlopt_infile, $fp);  curl_setopt ($ch, Curlopt_infilesize, FileSize ($SRC));  Curl_exec ($ch);  $error _no = Curl_errno ($ch);  Curl_close ($ch);  if ($error _no! = 0)  {     return 0;  } else{   return 1;}  } upload ("Images", "s.py", "aaa.py"); >

Summary : The above is the entire content of this article, I hope to be able to help you learn.

Related recommendations:

The method of PHP combined with session operation database

How PHP will localize remote images

How PHP accepts files and obtains suffix names

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.