I need to download data from the Bureau of Labor Statistics' public FTP server for analysis. I'm attempting to use PHP to retrieve a listing, but I'm not sure how to do it with a public FTP server - using no ftp_login results in "false" being returned, and attempting to login as anonymous hangs the script.
My code:
<?php
// set up basic connection
$ftp = ftp_connect("ftp.bls.gov");
ftp_login($ftp, "anonymous", "");
ftp_pasv($ftp, true);
var_dump(ftp_rawlist($ftp, "/pub/time.series/la/"));
?>
Your script works for me (see output), I get a nice directory listing. Please contact the system administration of the server your PHP script is running and ask for support. It looks like that this is a network configuration issue to me.
Additionally always check function return values for errors before you continue:
Excerpt from: How to Use Anonymous FTP (RFC 1635)
Try this Php code. Hope it'll be helpful: