This article mainly introduces the method of FTP file transfer in PHP based on curl. Interested friends can refer to it. I hope it will be helpful to everyone.
The details are as follows:
<?php function 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 it will be helpful to everyone's study.
Related recommendations:
How to operate the database with php combined with session
How to localize remote images in php
PHP method of accepting files and getting suffix names
The above is the detailed content of PHP method to implement FTP file transfer based on curl. For more information, please follow other related articles on the PHP Chinese website!