本篇文章主要介绍php基于curl实现ftp传输文件的方法,感兴趣的朋友参考下,希望对大家有所帮助。
具体如下:
<?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");
?>总结:以上就是本篇文的全部内容,希望能对大家的学习有所帮助。
相关推荐:
立即学习“PHP免费学习笔记(深入)”;
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号