连接正常时,无法使用PHP代码从aws实例访问ftp文件夹

My Php Code is, which have some error on aws server

$conn_id = ftp_connect("SERVERIP");
$ftp_user_name = "username";
$ftp_user_pass = "password";
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);        
// login with username and password
ftp_put($conn_id,$target_dir, $_FILES["UploadedImage"]["tmp_name"], FTP_BINARY);

Getting below error with when I send request from aws server, Seems like there is some problem to fetch ftp folder

Status: Date: Wed, 22 Mar 2017 08:09:16 GMT Last-Modified: Wed, 22 Mar 2017 08:09:16 +0000 Server: Apache/2.2.21 (Win32) PHP/5.3.10 X-Powered-By: PHP/5.3.10 ETag: "1490170156" Content-Language: en Access-Control-Allow-Origin: * Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0 Connection: Keep-Alive Content-Type: text/html Keep-Alive: timeout=5, max=100 Content-Length: 68 Expires: Sun, 19 Nov 1978 05:00:00 GMT Check Internet Connection/Router. Contact Local Administrator

You didn't really provide us much information that can be used to identify the problem.

Anyway, you are using active FTP mode. The active FTP mode hardly works these days due to ubiquitous firewalls and NATs. Particularly the AWS network in NATted. In general, you should always use the passive FTP mode.

For details, see my article on FTP active and passive modes.

In PHP, you switch to the passive mode by calling the ftp_pasv after the ftp_connect (or the ftp_login, if you use that).

$conn_id = ftp_connect("SERVERIP");

$ftp_user_name = "username";
$ftp_user_pass = "password";
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);        

// turn passive mode on
ftp_pasv($conn_id, true);