Thanks David.
I have already written something like you have below, which works well.
However, I think my host has their servers set up so I can't override
php settings, because I can't change the timeout.
But I plan to try running it via cron to see what happens.
steve
On Mar 7, 2007, at 4:44 PM, David Precious wrote:
On Wed, 7 Mar 2007, steve miller wrote:
I want to ftp the contents of a large directory from one server to
another (probably 300 files @ 20MB each).
I have the login and paths for both the sending server and the
receiving, but I don't have telnet access into them.
I have written php scripts to ftp them, but the scripts timeout after
about 10 files.
I've tried simply using an ftp client with 2 windows open, but that
is way slow.
Firstly, cron will be a good way to run the PHP scripts - you
shouldn't be
subject to the default 30 second timeout then, and it's automated,
which
is much nicer.
If you want to just deal with the timeout, then use set_timeout(0)
near
the top of your script to disable it.
If PHP has been compiled with the FTP extension, then you can do
something
simple like:
<?php
if (!function_exists('ftp_connect')) {
die("PHP doesn't have FTP support, sorry");
}
$conn = ftp_connect('ftp.example.com') || die('Failed to connect');
if (!ftp_login($conn, 'username', 'password')) {
die("Failed to log in to the FTP server");
}
foreach ($files as $file) {
if (ftp_put($conn, $remote_file, $file, 'FTP_BINARY')) {
echo("Uploaded $file");
} else {
echo("Failed to upload $file");
}
}
ftp_close($conn);
?>
That should give you enough of an idea to get started with.
See http://uk2.php.net/ftp for more info.
Cheers
Dave P
http://blog.preshweb.co.uk/
____ • The WDVL Discussion List from WDVL.COM • ____
To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED]
dl.sparklist.com or
use the web interface http://e-newsletters.internet.com/
discussionlists.html/
Send Your Posts To: [email protected]
To change subscription settings, add a password or view the web
interface:
http://intm-dl.sparklist.com/read/?forum=wdvltalk
________________ http://www.wdvl.com _______________________
You are currently subscribed to wdvltalk as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
[EMAIL PROTECTED]
To unsubscribe via postal mail, please contact us at:
Jupitermedia Corp.
Attn: Discussion List Management
475 Park Avenue South
New York, NY 10016
Please include the email address which you have been contacted with.
____ • The WDVL Discussion List from WDVL.COM • ____
To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] or
use the web interface http://e-newsletters.internet.com/discussionlists.html/
Send Your Posts To: [email protected]
To change subscription settings, add a password or view the web interface:
http://intm-dl.sparklist.com/read/?forum=wdvltalk
________________ http://www.wdvl.com _______________________
You are currently subscribed to wdvltalk as: unknown lmsubst tag argument: ''
To unsubscribe send a blank email to [EMAIL PROTECTED]
To unsubscribe via postal mail, please contact us at:
Jupitermedia Corp.
Attn: Discussion List Management
475 Park Avenue South
New York, NY 10016
Please include the email address which you have been contacted with.