[英]ftp_nlist returning boolean true - not working on server, is on dev
我已經編寫了一些代碼,可以訪問FTP服務器並提取平面文件。 它可以在WAMP(Windows; 5.3.10)的開發環境中工作,但在生產服務器(5.3.2-Linux)上,調用ftp_nlist時將失敗。
它坐在那里約30秒鍾,然后死於代碼錯誤消息[FTP] Unable to retrieve files in the directory
。
以下是相關代碼:
$link = ftp_connect(constant("FTP_SERVER"));
if(!$link)
die("Unable to open connection to FTP Server: " + constant("FTP_SERVER"));
if(!ftp_login($link,
constant("FTP_USER"),
constant("FTP_PASSWORD")))
die("Unable to login; check username and password.");
if(!ftp_chdir($link,
constant("FTP_PATH")))
die("Unable to change to directory: " + constant("FTP_PATH"));
ftp_pasv($link, true);
clearDownloadDir(); // Delete already downloaded files
/* Get a list of all files */
$files = ftp_nlist($link, '.');
if(!$files)
die("[FTP] Unable to retrieve files in the directory.");
常量在另一個文件中定義為:
define("FTP_SERVER", "ftp.{server}");
define("FTP_PATH", "./Australia/");
define("FTP_USER", "{user}");
define("FTP_PASSWORD", "{password}");
讓我感到驚訝的是它正在連接(事實證明它沒有死在ftp_connect上)並在本地工作。 FTP_NLIST返回布爾值TRUE(1)。 有任何想法嗎?
原來,運行此代碼的共享服務器上的防火牆阻止了FTP進入被動模式。 很奇怪。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.