note 47438 deleted from function.ftp-nb-fget by betz
| From: | betz@php.net | Date: | Tue, 16 Nov 2004 16:20:18 +0000 |
| Subject: | note 47438 deleted from function.ftp-nb-fget by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-80602@lists.php.net to get a copy of this message | ||
Note Submitter: pilif at pilif dot ch
----
If you want to monitor the progress of the download, you may use the filesize()-Function.
But note: The results of said function are cached, so you'll always get 0 bytes. Call
clearstatcache() before calling filesize() to determine the actual size of the downloaded file.
This may have performance implications, but if you want to provide the information, there's no
way around it.
Above sample extended:
<?php
// Initate the download
$ret = ftp_nb_get($my_connection, "test", "README", FTP_BINARY);
while ($ret == FTP_MOREDATA) {
clearstatcache(); // <- this is important
$dld = filesize($locfile);
if ( $dld > 0 ){
$i = ($fs/$dld)*100;
printf("\r\t%d%% downloaded", $i);
}
// Continue downloading...
$ret = ftp_nb_continue ($my_connection);
}
if ($ret != FTP_FINISHED) {
echo "There was an error downloading the file...";
exit(1);
}
?>
----
Reason: bad code