Jump to content

Very quick question: ftp_nb_put


jkds

Recommended Posts

Hi all, quick one:

 

Anyone know why ftp_nb_put returns either null, 1 or 2 instead of FTP_FAILED, FTP_FINISHED or FTP_MOREDATA?

I'm running the upload like this:

 

$ret = ftp_nb_put($conn_id, $target_file, $source_file, FTP_BINARY);
while ($ret == FTP_MOREDATA) {
// Continue uploading...
echo 'Continuing, returned '.$ret.'<br>';
$ret = ftp_nb_continue($conn_id);
}
if ($ret != FTP_FINISHED) {
echo 'Failed, returned '.$ret;
}else{
echo 'Success, returned '.$ret;
}

 

...and I'm getting return values 2 for FTP_MOREDATA, 1 for FTP_FINISHED and null for FTP_FAILED.

 

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/197978-very-quick-question-ftp_nb_put/
Share on other sites

Thanks for the link oni-kun. I have, as you may expect, already referred to the manual page...

 

However, the PHP manual states that the expected return should be FTP_FAILED or FTP_FINISHED or FTP_MOREDATA. I'm getting null, 1 or 2 as return values. That's the problem I was describing.

Thanks for the link oni-kun. I have, as you may expect, already referred to the manual page...

 

However, the PHP manual states that the expected return should be FTP_FAILED or FTP_FINISHED or FTP_MOREDATA. I'm getting null, 1 or 2 as return values. That's the problem I was describing.

 

If you've read the manual, You'd see they use constants. What happens if you type "print FTP_FINISHED" ? It's a constant.

 

FTP_FINISHED == 1

FTP_MOREDATA == 2

 

Therefor 1 and 2 are the proper responses. Null is a very common response if the stream cannot be connected (false == 0), and/or if there is an error in the function.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.