ftp_login期望参数1是一个资源 [英] ftp_login expects parameter 1 to be a resource

查看:147
本文介绍了ftp_login期望参数1是一个资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


警告:ftp_login()预计会发生以下错误:参数1是资源,布尔在第65行给出的/home/content/98/10339998/html/upload.php中给出
FTP连接遇到错误!试图连接到thelegendmaker.net .... p>

引起的:

  //建立到ftp服务器的连接
$ conn_id = ftp_connect(thelegendmaker.net);

//使用用户名和密码登录
$ login_result = ftp_login($ conn_id,$ ftp_user_name,$ ftp_user_pass);

有人知道为什么会发生这种情况吗?我尝试过使用没有引号,双引号和单引号,但都没有工作。事实上,当 ftp_connect() 无法连接到FTP服务器,它将返回FALSE而不是通常返回的资源链接标识符。使用ping



检查您的FTP服务器是否还活着您可以像

  if($ conn_id){
//使用用户名和密码登录
$ login_result = ftp_login($ conn_id,$ ftp_user_name,$ ftp_user_pass);
}


I'm trying to upload some files with FTP and I'm having the following error:

Warning: ftp_login() expects parameter 1 to be resource, boolean given in /home/content/98/10339998/html/upload.php on line 65 FTP connection has encountered an error!Attempted to connect to thelegendmaker.net....

caused by:

// set up a connection to ftp server
$conn_id = ftp_connect("thelegendmaker.net");

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

Does anyone know why this is happening? I've tried using no quotes, double quotes, and single quotes and none work.

解决方案

The problem has it basis in the fact that, when ftp_connect() cannot connect to a FTP Server it returns FALSE instead of the resource link identifier it generally returns. Check whether your FTP server is alive using ping

you can do like

if($conn_id){
     // login with username and password
     $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
}

这篇关于ftp_login期望参数1是一个资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆