我正在尝试使用 FTP 上传一些文件,但出现以下错误:
I'm trying to upload some files with FTP and I'm having the following error:
警告:ftp_login() 期望参数 1 是资源,在第 65 行的/home/content/98/10339998/html/upload.php 中给出布尔值FTP连接遇到错误!尝试连接到legendmaker.net....
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....
原因:
// 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.
问题的根源在于,当ftp_connect()
无法连接到它返回 FALSE 而不是它通常返回的资源链接标识符的 FTP 服务器.使用 ping 检查您的 FTP 服务器是否处于活动状态
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
你可以这样做
if($conn_id){
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
}
这篇关于ftp_login 期望参数 1 是资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!