CURL FTP上传 发表于 2015-09-03 | 分类于 PHP日记 | 评论数: | 阅读次数: 本文字数: 1.5k | 阅读时长 ≈ 3 分钟 1234567891011121314151617181920212223<?php //作者: 大药瓶子 $ch = curl_init(); $file='install.php'; $fp = fopen($file, 'r'); curl_setopt($ch, CURLOPT_URL, 'ftp://14.152.85.84/wwwroot/'.$file); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_USERPWD, "eooo:xuchangyu");//FTP用户名:密码 curl_setopt($ch, CURLOPT_UPLOAD,1); curl_setopt($ch, CURLOPT_INFILE,$fp); curl_setopt($ch, CURLOPT_INFILESIZE,filesize($file)); curl_exec($ch); $error_no = curl_errno($ch); curl_close ($ch); fclose($fp); if ($error_no != 0) { echo '0'; }else{ echo '1'; }?> 实例2 12345678910111213141516171819202122232425262728293031323334353637383940414243<?phpset_time_limit(0);//页面地址$url2 = 'http://uploadv2.zhuanmi.net:443/web/upload.do?userid=1381723&maxsize=2147483648&folderid=12233121&key=47b9104f702e3957c7fbc07866ab258e';//这里是要上传的地址$name =$_GET["name"];//$name = urlencode($name);$post = array("excel"=>"@$name",//这里是要上传的文件,key与后台处理文件对应);//访问页面2$ch2=curl_init($url2);curl_setopt($ch2, 'Mozilla/5.0 (Linux; U; Android 2.3; en-us) AppleWebKit/999 (KHTML, like Gecko) Safari/999.9');curl_setopt($ch2, CURLOPT_POST, 1);curl_setopt($ch2, CURLOPT_POSTFIELDS, $post); curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch2, CURLOPT_REFERER, null);$content2 = curl_exec($ch2);curl_close($ch2);echo $content2; $result = unlink($name); ?> 打赏 微信支付 支付宝