Page 1 of 1

ftp problems

Posted: Fri Mar 14, 2003 9:06 am
by Bill H
I am having a problem with an ftp connection on a unix server.

Code: Select all

<?php
// set up basic connection
$conn_id = ftp_connect("www.sitename.com");

if (!$conn_id)
     echo "FTP connection not made successfully.";
else
{
     // login with username and password
     $login_result = ftp_login($conn_id, "username", "password");

     // check connection
     if (!$login_result)
           echo "FTP connection has failed!";
     else 
     {    echo "Connected to proper server.";

          echo ftp_pwd($conn_id);
          echo "<br>";

          ftp_chdir($conn_id, "newdir");
          echo "<br>";

         ftp_get($conn_id, "C:/Temporary/filename.doc", "filename.doc",   FTP_BINARY);
          echo "<br>";
          ftp_get($conn_id, "C:/Temporary/filename.doc", "newdir/filename.doc", FTP_BINARY);
          echo "<br>";
     }
     // close the FTP stream
     ftp_close($conn_id);
}
?>
The above code echoes
Connected to proper server
/
Warning: ftp_chdir(): newdir: No such file or directory.
Warning: ftp_get: filename.doc: No such file or directory.
Warning: ftp_get: newdir/filename.doc: No such file or directory.
A call to ftp_nlist($conn_id, "/"); returns an empty list.

It seems it is connecting and logging in but cannot see the directories and files that are there. (They are there. I use WS_FTP and can see them.)

What am I missing?

Posted: Fri Mar 14, 2003 9:13 am
by hedge
What version of php, what OS. I ran into this problem with php 4.2 on windows, the function was fixed in 4.3

Posted: Fri Mar 14, 2003 9:39 am
by Bill H
oops, my bad.
My hosting company has a few little wierd quirks and I wasn't logging in where I thought I was.
I needed to change to the "/www" directory first.

But I still have a problem with the file download.
Warning: ftp_get(): error opening C:/Temporary/filename.doc in /data/web/.../ftp_test.php on line 19 (the ftp_get() line)
What do I not know about creating a file on the local disk?

Posted: Fri Mar 14, 2003 7:49 pm
by Bill H
Found out what I didn't know.
This function cannot access the machine on which the browser is running.
:(