我试图从我的机器(客户端)上传一个文件到FileZilla服务器(服务器端)来存储网页文件。当试图通过PHP连接到FileZilla时,我会收到以下错误消息:
Connection failed: Connection refused通常,当登录凭据不正确时,我会期望错误,但是,在这种情况下,它们是正确的。
我的问题是:你能通过PHP连接到FileZilla吗?我相信答案肯定是“是”,但由于目前的技术困难,否则我不会感到惊讶。
连接函数的格式设置可能有错误。
var $host = "xx.xx.xx.xx";
var $user = "xx";
var $pass = "xx";
var $connect;
function serverConnection()
{
$conection = mysqli_connect($this->host, $this->user, $this->pass) or die
("Connection failed: " . mysqli_connect_error());
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
} else {
$this->connect = $conection;
}
return $this->connect;
}其目标是能够将文件从表单上传到FileZilla,充当用户配置图片的角色。
发布于 2018-10-28 13:06:08
目前,您使用的是连接到数据库服务器的mysqli_connect,您需要连接到FTP服务器,所以您应该使用FTP函数。首先应该是连接,然后是登录。
它应该是这样的:
$server = 'myServer';
$user = 'myUsername';
$pass = 'myPassword';
$connect = ftp_connect($server) or die('Could not connect to FTP-server.');
if(ftp_login($connect, $user, $pass)) {
echo 'Connected to FTP-server.';
}https://stackoverflow.com/questions/53031755
复制相似问题