通过php的ftp函数上传文件

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

 
//ftp,使文件传到服务器上
protected function ftp_send($des,$src)
{
    $ftp_ip   = 'ip地址';
    $ftp_user = 'ftp用户名';
    $ftp_pass = 'ftp密码';
     
    $conn_id = ftp_connect($ftp_ip) or die("Couldn't connect to $ftp_ip");

    if(@ftp_login($conn_id, $ftp_user, $ftp_pass)) 
    {
         
        $path = dirname($des);
         
        if (!ftp_chdir($conn_id, $path)) 
        {
            ftp_mkdir($conn_id,$path);
        }
         
        $upload = ftp_put($conn_id,$des,$src,FTP_BINARY);
        if($upload)
        {
            ftp_close($conn_id);
        }
        else
        {
            exit('ftp error!');
        }
        
    } 
    else
    {
        echo "Couldn't connect as $ftp_user\\n";
        exit;
    }
     
}