The SF PHP Meetup Group Message Board › PHP Warning: ftp_put(): Switching to Binary mode.

PHP Warning: ftp_put(): Switching to Binary mode.

Alex Albino
Posted Nov 16, 2011 7:17 PM
user 13177649
Vallejo, CA
Post #: 6
Send an Email Post a Greeting
I tried using PHP's ftp_put() method to upload a .gz file into a remote FTP slot in binary mode.

The remote server only allows "ACTIVE", not "PASSIVE".

I'm able to execute the script just fine when I run it off of my development machine (ubuntu 11.10 command line php5).
The file is uploaded just fine.

When I run the exact same script on our server (Amazon EC2 instance), the script chokes on the call to PHP's ftp_put() method with the following warning:

"PHP Warning: ftp_put(): Switching to Binary mode."

Interestingly enough... When I attempt to manually upload the file using the "ftp" command (bash shell) on the server, I cannot use the "ls" command, or the "put" command.
Use of either of these commands results in a message that reads "421 Service not available, remote server has closed connection"

I need help figuring out what needs to be configured (and if it's within my reach in an Amazon EC2 instance) or what would cause this issue.

Thanks in advance, I'll owe you a beer if you figure it out! biggrin

- Alex Albino

(I've used **** in place of actual user name, remote server, and password values)

$ ftp
ftp> open ftp.****.com
Connected to ftp-vip.vir.****.com.
220 **** FTP#1 Service - All Transfers Are Logged - YOU MUST USE ACTIVE MODE
Name (ftp.****.com:****): ****
331 Please specify the password.
Password:****
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
421 Service not available, remote server has closed connection
ftp>
Alex Albino
Posted Nov 17, 2011 10:24 AM
user 13177649
Vallejo, CA
Post #: 7
Send an Email Post a Greeting
...Turns out it had everything to do with the way Firewalls and NAT redirection are set up...and it was out of my hands. So...guess that's that. :-)

(If anyone ever reads this, just know that there is no sane reason anyone should ever use an unencrypted active FTP connection. It's a security no-no that is just begging for trouble. I had to try due to a decision the powers that be made, not out of my own will. Fortunately, I was finally able to reason with said powers, and switch us over to SFTP instead.)
Ted Paff
Posted Dec 4, 2011 11:18 AM
user 14245987
Berkeley, CA
Post #: 3
Send an Email Post a Greeting
Said powers appreciate your persistence! smile
Powered by mvnForum

IGN

Food, beverages, organizer time and give-aways.

Engineyard/Orchestra.io

Drinks at the 21st Amendment for the SFPHP Meeting-After-the-Meeting

O'Reilly User Group Program

The O'Reilly User Group Program provides the great books we get monthly.

People in this
Meetup are also in:

Log in

Not registered with us yet?

Sign up

Meetup members, Log in

or
By clicking the "Sign up using Facebook" or "Sign up" buttons above, you agree to Meetup's Terms of Service