...

View Full Version : FTP Script Resume a file



colabus
06-03-2004, 07:09 AM
$FTPip=123.123.123.123;
$FTPport=123;
$LOGfile=123.log;
$LOGsize=filesize($LOGfile);

$FTPid = ftp_connect($FTPip,$FTPport,5);
if ($FTPid) {
echo "connected..<br>";
if (ftp_login($FTPid,$FTPuser,$FTPpass)) {
echo "logged in..";
if (ftp_get($FTPid,$LOGfile,$LOGfile,FTP_BINARY,$LOGsize)) {
echo "Successfully updated $LOGfile..";
}
}
}
ftp_close($FTPid);


I tried using fopen($LOGfile,'a') but it didn't work.. it connects, logs in, just doesn't get the file.. help

firepages
06-03-2004, 09:22 AM
the last argument to ftp_get is the offset of where in the file to start reading , e.g. if you had previously downloaed the first 50 bytes and the connection was lost , you would resume with an offset of 51 ... , so if your local copy of the logfile is the same size as, or smaller than the remote file, then you will download nothing as you are sending the filesize of the local copy as the offset.

in other words try ,


<?
ftp_get($FTPid,$LOGfile,$LOGfile,FTP_BINARY);
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum