Hello everybody,
If someone will try to download files to the same local file (some temporary file), like shown here:
<?php
foreach ($files as $key=>$path) {
...
$result = ftp_get($ftpConnId, 'temp.tmp', $path, FTP_BINARY);
...
}
?>
please take in consideration the fact that you will have big problems with downloading (getting) hole files. In other words temp.tmp file always will have the same size equal to first downloaded file despite the real size of downloading file. I have not idea what is the reason!
If someone will think that problem is just in getting proper file size (which you will get using filssize() function) he will be mistaken. The download files size is not equal to source files size materially, that means fflush() function will not solve the problem (I have tried this as well).
Finally the solution was founded: before downloading a file you will need to delete local file if such exist (temp.tmp). So working code will look like:
<?php
foreach ($files as $key=>$path) {
...
if (file_exists('temp.tmp')) {
unlink('temp.tmp');
}
$result = ftp_get($ftpConnId, 'temp.tmp', $path, FTP_BINARY);
...
}
?>
Good luck in scripting :-)
Vitali Simsive