2013-02-15 145 views
1

我想上传一个文件到多个FTP,但它显示错误:通过FTP在php上传文件

ftp_put() [function.ftp-put]: php_connect_nonb() failed: Operation now in progress (115)

,看一下我的代码

foreach ($channel_details as $channel_list) 
{ 

    if(isset($connection)) 
    unset($connection); 
    if(isset($login)) 
    unset($login); 
    if(isset($upload)) 
    unset($upload); 

    $server = $channel_list['channel']; 
    $ftp_user_name = $channel_list['username']; 
    $ftp_user_pass = $channel_list['password']; 

    $source='file_push.html'; 


    $dest='/public_html/'.$path.$file; 


    $connection = ftp_connect($server) or die("Couldn't connect to ftp server"); 


    $login = ftp_login($connection, $ftp_user_name, $ftp_user_pass); 

    // turn passive mode on 
    ftp_pasv($connection, true); 

    if (!$connection || !$login) { die('Connection attempt failed!'); } 

    $upload = ftp_put($connection, $dest, $source, FTP_ASCII); 
    if (!$upload) { echo 'FTP upload failed!'; } 

    ftp_close($connection); 

} 

回答