1
votes

I am trying to upload a file to an FTP Server via a PHP script. The connection works and I can create subdirectories on the server. However ftp_put gives the following error:

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

Warning: ftp_nb_put() [function.ftp-nb-put]: Type set to I in ....

This is the script

$conn_id = ftp_ssl_connect($ftpHost);#
$login_result = ftp_login($conn_id, $ftpUser, $ftpPw);

ftp_pasv($conn_id, true);


// Verbindung überprüfen
if ((!$conn_id) || (!$login_result))
    {
    // no Connection

    }else{
    // Connection WORKS!

    if(!@ftp_chdir ( $conn_id , $ftpDir )){
        // ftp_mkdir WORKS!
            @ftp_mkdir($conn_id, $ftpDir);
        }//if(!@ftp_chdir ( $conn_id , $ftpDir )){


    if (ftp_put($conn_id, $myFile, $targetfile, FTP_BINARY)) {
                 // Upload success: NOT WORKING!

            }       


    }

}//if ((!$conn_id) || (!$login_result))

How can I change my script to get my desired behaviour?

1
where is $myFile, $targetfile defined? where is the part to change dir when you creating a dir? why do you use @ to suppress warnings and notices?donald123
try it with passive mode off by using false in second parameter of ftp_pasv function. If it works, then it means you are behind the firewall.codelearner
'ftp_pasv' 'false' does not working. @donald123: the files are available and everything works on my private demo FTP Server, but not on the live system.cuSoon
This is FTPS, not SFTP. They are very different things.Kenster
Do you have an access to FTP server log? Can you share it?Martin Prikryl

1 Answers

0
votes

As you didn't provide us much useful information, I can only suggest that this is a network issue that prevents opening a data transfer connection.

For details refer to my article on FTP connection modes and necessary network configuration.

If you provide more details, like an FTP server log or any kind of network log (e.g. from Wireshark), you will likely get more concrete answers.