Reputation: 41
Before saying anything. I have searched for a solution on this. I'm trying to figure this out for a while now.
I am currently trying to show the progress of a ftp download by echo'ing every time a file get's downloaded.
This is part of my code:
<?php
header('Content-type: text/html; charset=utf-8');
header('Cache-Control: no-cache, must-revalidate');
header('X-Accel-Buffering: no');
// ftp connection stuff goes here
$string_length = 4096;
for ($i=0; $i < $filesLength; $i++) {
if (ftp_get($ftp_conn, './downloads/'.$files[$i]['local'], $files[$i]['server'], FTP_ASCII)) {
echo 'File: '.$files[$i]['local'].' saved.<br>';
// $string = str_repeat('.', $string_length);
// echo '<div style="display:none;">'.$string . '</div>';
ob_flush();
flush();
} else {
echo "Error";
}
}
Theres 2 commented line there that if I uncomment everything it works.
What should I do to make this work?
Upvotes: 1
Views: 228
Reputation: 41
I haven't found a proper solution I guess.
I ended up using a 4kb string to trigger the flush.
This works, but not as intended.
Upvotes: 0