3
votes

I'm getting a weird FTP failure in a PHP script. I've recreated the failure just using command line FTP, so I think I can eliminate PHP from my enquiries.

Using command line FTP in Ubuntu 10.10, I can connect to my FTP server, log in, list directories, etc. However, when I try to transfer a file from my local machine to the FTP server using "put" I get a "553 Could not create file" error. I get the same error in active and passive modes. Transfer is set to binary.

When I run FileZilla on the same machine and connect to the same FTP server using the same credentials, and try to transfer the same file to the same destination directory, the transfer works just fine, after defaulting to binary and passive mode.

FWIW, the PHP script (which is a simple ftp_connect, ftp_login and ftp_put) using the same details fails with "Illegal PORT command", although I suspect this is just PHP's interpretation of the same error I get from command line FTP. Again, this error occurs in both active and passive FTP modes.

1
Can you see anything in Filezilla's logs? wiki.filezilla-project.org/Logs It should tell you exactly what commands are being sent, which may give a clue as to what is going wrong.Kevin Lacquement
I would recommend curl before the php built in php-functions. It's an awsome library. stackoverflow.com/questions/1178425/…Teson

1 Answers

2
votes

FileZilla and ftp command probably starts in a different directories. You can setup starting remote directory in FileZilla and you have to go to the same location from command line.

Try using pwd command after logging in from command line client, it will show current working directory, compare that with the one FileZilla is using and then go to the correct directory with a cd command.