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 是资源
- 没有作曲家的 PSR4 自动加载 2022-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- Laravel 仓库 2022-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
