简体   繁体   English

PHP FTP文件上传不起作用

[英]PHP FTP file upload does not work

I have pretty strange problem. 我有一个很奇怪的问题。 A web application moved from one server to another one. Web应用程序从一台服务器移至另一台服务器。 Since then the FTP upload is not working anymore. 从那时起,FTP上传不再起作用。

$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'. 错误消息是“无法上传FTP文件”。 I checked everything I know of. 我检查了我所知道的一切。 Selinux is disabled. Selinux被禁用。 When I do a FTP upload by hand (on the console with the tool "ftp") it works. 当我手动进行FTP上传时(在控制台上使用“ ftp”工具),它可以工作。 The file names are randomly generated and always look like this: erefsdgftef.xml (No spaces.) 文件名是随机生成的,始终看起来像这样:erefsdgftef.xml(无空格。)

This code is part of the last order step within Magento and will therefore always be initiated through the apache httpd. 此代码是Magento中最后一个步骤的一部分,因此将始终通过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 http://nl3.php.net/manual/en/function.ftp-pasv.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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