0

I need to access a list of files in an FTP server, but for some reason, I cannot connect to it.

<?php
    $ftp_server = "ftp.nhc.noaa.gov";
    $ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
    $login = ftp_login($ftp_conn, "anonymous", "email@gmail.com");

    $file_list = ftp_nlist($ftp_conn, ".");
    var_dump($file_list);

    ftp_close($ftp_conn);
?>

When I run the code above, I get this error:

Warning: ftp_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/prww/public_html/hurricane/test.php on line 3

How can I successfully connect to this server and get a list of its files?

Connor C
  • 37
  • 5
  • Possible duplicate of [php\_network\_getaddresses: getaddrinfo failed: Name or service not known](https://stackoverflow.com/questions/2661546/php-network-getaddresses-getaddrinfo-failed-name-or-service-not-known) – Matt Jun 14 '17 at 19:49
  • Looks like the DNS resolution on that system does not work as expected. – arkascha Jun 14 '17 at 19:52
  • @j08691 I FTP functions were not enabled, the code would not even run. – Martin Prikryl Jun 15 '17 at 06:14

0 Answers0