PHP上传文件到FTP


$ftp_server = "192.168.2.2";
$ftp_user = "000000";
$ftp_pass = "000000";

// set up a connection or die
$conn_id = ftp_connect($ftp_server,22,100) or die("Couldn't connect to $ftp_server");
$login_result = ftp_login($conn_id, $ftp_user, $ftp_pass);
ftp_pasv($conn_id, true);
if ((!$conn_id) || (!$login_result)) {
echo "连接失败";
exit;
}

//循环执行上传
if ( $urlstr !== ""){
foreach ($url as $k => $v){
$source_file= substr($v,1); //本地文件地址
$destination_file= $v; //目标地址
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY) or die("Couldn't connect to $ftp_server");
}

}
ftp_close($conn_id);
智能推荐

注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告