The local file must exist. I just did a PHP FTP script where I would use
file_exists() to check for local file. If it exists, delete it. Then
touch($localFile) before initiating download.
[EMAIL PROTECTED] wrote:
> I am attempting to set up a cron job to download files off of a ftp
> server every day. I am planning on doing it in php, and here is what I
> have so far.
>
> <?php
>
> $ftp_server = 'www.mywebsever.com';
> $ftp_user_name = 'myusername';
> $ftp_user_pass = 'mypass';
>
> // set up basic connection
> $conn_id = ftp_connect($ftp_server);
>
> // login with username and password
> $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
>
> $local_file = 'test.htm';
> $server_file = 'test.htm';
>
> if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
> echo "Successfully downloaded to $local_file<br>\n";
> } else {
> echo " **** Error downloading $server_file to $local_file<br>\n";
> }
>
> // close the connection
> ftp_close($conn_id);
>
> ?>
>
> This is pretty much verbatim off of a tutorial site that i found. For
> some reason everytime I run it I get the error message " **** Error
> downloading $server_file to $local_file<br>\n".
>
> I have found that it connects fine. I put in some code to get a
> directory listing and it returns a list fine.
>
> The problem seems to be the name of the file, or perhaps permissions.
> I am not sure which. Any help or trouble shooting advice would be
> greatly appreciated.
>
> Thanks,
> Brett
>
>
> >
>
--
Joshua Benner
http://bennerweb.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---