无法使用PHP连接FTP服务器,ftp_connect() [英] Cannot connect with FTP server with PHP , ftp_connect()

查看:84
本文介绍了无法使用PHP连接FTP服务器,ftp_connect()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <?php 

$ ftp_server =http://ftp.mozilla.org/pub/mozilla.org/;

$ conn_id = ftp_connect($ ftp_server)或死(无法连接到$ ftp_server);

?>

但它会返回此错误:


警告:ftp_connect()[function.ftp-connect]:php_network_getaddresses:getaddrinfo失败:没有这样的主机是已知的。在D:\wamp\www\ftp2.php在第6行

尽管这是一种非常常见的错误类型,我仍然找不到任何解决方案。任何人都可以提供一些可能的解决方案吗?



谢谢你的时间。

由于这是一个FTP连接,因此您只能提供ftp服务器主机名,而不是主机名和目录路径,以及不相关的 http://

  $ ftp_server =ftp.mozilla.org; 
$ conn_id = ftp_connect($ ftp_server)或死(无法连接到$ ftp_server);

//然后chdir到正确的目录:
ftp_chdir($ conn_id,/pub/mozilla.org);

请参阅 PHP的FTP功能的完整文档


I was trying to connect with ftp server using ftp_connect() function of PHP as shown below:

<?php

$ftp_server = "http://ftp.mozilla.org/pub/mozilla.org/";

$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server"); 

?>

But it returns this error:

Warning: ftp_connect() [function.ftp-connect]: php_network_getaddresses: getaddrinfo failed: No such host is known. in D:\wamp\www\ftp2.php on line 6

Although this is a very common type of error, I still cannot find any solution. Can anyone provide some possible solutions?

Thank you for your time.

解决方案

You must supply only the ftp server hostname, rather than the hostname and directory path, and the irrelevant http:// since this is an FTP connection.

$ftp_server = "ftp.mozilla.org";
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server"); 

// Then chdir to the correct directory:
ftp_chdir($conn_id, "/pub/mozilla.org");

See the full documentation of PHP's FTP functions.

这篇关于无法使用PHP连接FTP服务器,ftp_connect()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆