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 是资源
基础教程推荐
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何替换eregi() 2022-01-01
