简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM