使用PHP测试FTP连接 [英] Test FTP connection with PHP
问题描述
我正在使用下面的PHP脚本来测试FTP连接。目前它正在打印一组文件,如果它成功连接的话。
如果它能够连接,我怎样才能让它显示信息?像'连接成功'。
$ con = ftp_connect($ server)或die(Could not connect);
ftp_login($ con,$ username,$ password);
print_r(ftp_nlist($ con,。));
ftp_close($ con);
编辑
<现在我已经开始工作了,但是,我已经在MediaTemple服务器上的几个域中测试过了,他们都似乎超时了。然而,它适用于我尝试过的所有其他域。他们的服务器是否阻止了请求?
只要检查 I am using the PHP script below to test FTP connections. Currently it is printing an array of the files, if it successfully connects. How can I get it to also display a message, if it is able to connect? Like 'Connection Successful'. EDIT I have it working now but, I've tested this on a few domains I have on a MediaTemple server and they all seem be timing out. Yet, it works with all other domains I have tried. Are their servers blocking the request? Simply do a check if Like: References: 这篇关于使用PHP测试FTP连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! ftp_nlist()$ c
$ p
$ b $ echo is_array(ftp_nlist( $ con,。))? '连接!':'不连接! :
$con = ftp_connect($server) or die("Couldn't connect");
ftp_login($con, $username, $password);
print_r(ftp_nlist($con, "."));
ftp_close($con);
ftp_nlist()
is an array.echo is_array(ftp_nlist($con, ".")) ? 'Connected!' : 'not Connected! :(';