ftp_login expects parameter 1 to be a resource(ftp_login 期望参数 1 是资源)
问题描述
我正在尝试使用 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 是资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:ftp_login 期望参数 1 是资源
基础教程推荐
- 使用 scandir() 在目录中查找文件夹 (PHP) 2022-01-01
- Yii2 - 在运行时设置邮件传输参数 2022-01-01
- php中的PDF导出 2022-01-01
- PHPUnit 的 Selenium 2 文档到底在哪里? 2022-01-01
- 将变量从树枝传递给 js 2022-01-01
- 主题化 Drupal 7 的 Ubercart “/cart"页 2021-01-01
- 如何在数学上评估像“2-1"这样的字符串?产生“1"? 2022-01-01
- php中的foreach复选框POST 2021-01-01
- php 7.4 在写入变量中的 Twig 问题 2022-01-01
- Web 服务器如何处理请求? 2021-01-01
