2

I'm trying to do an ftp upload between my website and a remote server.

I'm getting this error PHP Warning: ftp_put(): php_connect_nonb() failed: Operation now in progress (115).

I did research and I believe this is the problem http://www.elitehosts.com/blog/php-ftp-passive-ftp-server-behind-nat-nightmare/

The thing is, I cannot download the patch because I'm using Godaddy Cpanel, and they said the hosting we have does not allow it and I also cannot ssh into it to be able to run command line.

I read that in PHP v5.6+ the patch was applied but I cannot get ftp_set_option($ftpconn, USEPASVADDRESS, true); to work. It doesn't recognize USEPASVADDRESS, which I thought it would because I'm using v5.6.22.

danielle
  • 21
  • 1
  • 2
  • And the question is? The FTP server is broken/misconfigured - fix it. – Martin Prikryl Aug 16 '16 at 20:13
  • I have the same problem. Did you figure out how to solve it? – Guille Acosta Aug 17 '16 at 20:59
  • @Martin, The question is, obviously, how to get around it. Alternatives to send files in PHP between servers, this is a PHP ftp ERROR that was RESOLVED in a later PHP version (that I cant get bc of Godaddy). Or maybe someone has experienced this and knows the config that needs to be done on the server to fix it. Trust me I did my research. If what I explained in my question sounds familiar to you, then yes please reach out and give me some advice. If you have never heard of this issue then please don't even bother commenting on here. I'm looking for people who've experienced this issue – danielle Aug 18 '16 at 13:32
  • @Guille, No I haven't got around it. Check your PHP version. If you are able to get a version above 5.6 then the patch should be included in that version. If not, follow the instructions in the link I provided in my post and apply the patch yourself if you can – danielle Aug 18 '16 at 13:34
  • It's not PHP bug, it's misconfigured FTP server. The newer versions of PHP can just workaround the problem. If you need help fixing the server, the Stack Overflow is not the right place to ask. Go to [su] or [sf]. – Martin Prikryl Aug 18 '16 at 13:38

1 Answers1

5

Maybe you've already managed to get around it, but the correct constant to use is FTP_USEPASVADDRESS, not just USEPASVADDRESS, regardless of what you can find at the nightmare page. That's independent of Godaddy or other hosting (but please note that I don't use Godaddy, so I can't bet it works there).

Moreover, the example at the nightmare page can be misleading, because it reports the code to make PHP behave as if that option didn't exist at all (e.g. make it behave like it already does by default):

ftp_set_option($ftpconn, USEPASVADDRESS, true);
echo "USEPASVADDRESS Value: " . ftp_get_option($ftpconn, USEPASVADDRESS) ? '1' : '0';
ftp_pasv($ftpconn, true);

I think the best example that page could give would be something like this instead:

ftp_set_option($ftpconn, FTP_USEPASVADDRESS, false);
echo "FTP_USEPASVADDRESS Value: " . ftp_get_option($ftpconn, FTP_USEPASVADDRESS) ? '1' : '0';
ftp_pasv($ftpconn, true);

e.g. it could show how to actually use that option, not how to waste a line of code to set an option to its default value.

Lucio Crusca
  • 1,277
  • 3
  • 15
  • 41