The docs on php.net are fairly simple. Rightly so, in my opinion, since the use of this function seems pretty straight forward. I'm clearly doing something wrong. Here is my code:
Code: Select all
<?php
$conn = ftp_connect("idx.fnismls.com") or die("Could not connect");
ftp_login($conn,"xxxxxxx","xxxxxxxx"); // connection, user, pass
$files = array();
$files = ftp_nlist($conn,"idx");
// get todays day, format: YYYYMMDD
$timestamp = time() - (24 * 60 * 60); // for the day before
$yesterday = date('Ymd', $timestamp);
//print $yesterday . '<br /><br />';
for($x = 0; $x < count($files); $x++)
{
$file = $files[$x];
$local = $file;
if($file != "idx/." && $file != "idx/..")
{
if(strstr($file, $yesterday))
{
//print $file . '<br />';
ftp_get($conn, $local, $file, FTP_BINARY);
}
elseif(strstr($file, '.gz'))
{
//print $file . '<br />';
ftp_get($conn, $local, $file, FTP_BINARY);
}
}
}
ftp_close($conn);
?>
Warning: ftp_get(idx/users.txt.gz) [function.ftp-get]: failed to open stream: No such file or directory in /home/lassonet/public_html/idx/get_data.php on line 30
Warning: ftp_get() [function.ftp-get]: Error opening idx/users.txt.gz in /home/lassonet/public_html/idx/get_data.php on line 30
I get that for every file I am trying to download. So...my question is, what am I doing wrong? If I can display the names of the exact files I want, why can't I get them?
I'm lost. I don't know if it's a permissions issue, a coding error, or what. All I want to do is log into a remote ftp server, and then download to my web server all of the contents of a certain directory. Sounds simple, but I'm having some issues with it.
Any help would be great.
Thanks,
Caleb