PHP FTP file upload does not work
I have pretty strange problem. A web application moved from one server to 开发者_高级运维another one. Since then the FTP upload is not working anymore.
$ftp = ftp_connect('ftphost');
if ($ftp == false) {
error_log('FTP Connect not possible');
}
$fp = fopen($filename, 'r');
if ($fp == false) {
error_log('Opening file not possible');
}
$login = ftp_login($ftp, 'username', 'password');
if ($login == false) {
error_log('FTP login not possible');
}
$status = ftp_fput($ftp, basename($filename), $fp, FTP_BINARY);
if ($status == false) {
error_log('FTP file upload not possible');
}
The error message is 'FTP file upload not possible'. I checked everything I know of. Selinux is disabled. When I do a FTP upload by hand (on the console with the tool "ftp") it works. The file names are randomly generated and always look like this: erefsdgftef.xml (No spaces.)
This code is part of the last order step within Magento and will therefore always be initiated through the apache httpd.
I don't get more error messages than the one posted before.
Something with the server configuration must be different on the new server. Does someone have more ideas?
Not sure this is your answer but did you already tried to do it in passive mode?
http://nl3.php.net/manual/en/function.ftp-pasv.php
精彩评论