next Posted July 30, 2008 Share Posted July 30, 2008 How can i make a progress bar or a simple text tracking of what is being uploaded? I currently have this code: <?php $server = '***'; $username = '***'; $password = '***'; $x = dir('S:\Accounting Scanning\LTD\2008\8724'); //if directory doesn't exist if($x == false) exit(); //get all file names and store them in "uploads" array while($f = $x->read()) { if(is_file($x->path . '\\' . $f) && $f != 'Thumbs.db') $uploads[] = $f; } $total_files = sizeof($uploads); //FTP try { //connect and login $fth = ftp_connect($server); ftp_login($fth, $username, $password); //change current directory ftp_chdir($fth, 'LTD'); //if files were found in the directory, lst them and close the connection $files = ftp_nlist($fth, '.'); if($files) { echo 'these files were found in LTD directory: <br />'; echo '<ul>'; foreach($files As $key => $file) echo '<li>'. $file .'</li>'; echo '</ul>'; ftp_close($fth); exit(); } //if no files were found in the directory, proceed with upload foreach($uploads As $key => $file) { if(!ftp_put($fth, $file, $x->path . "\\$file", FTP_BINARY)) $errors[] .= "<li>" . $x->path . "\\$file</li>"; else { $i++; $left = $total_files - $i; echo "currently uploading $file ---------------- $left files left to upload.<br />"; } } if($errors) { echo '<ul>'; foreach($errors as $key => $error) echo $error; echo '</ul>'; } ftp_close($fth); } catch(Exception $e) { echo $e->getMessage(); exit(); } ?> but this code displays my progress after all uploading is done, which is no good. Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/117372-solved-ftp-progress/ Share on other sites More sharing options...
paul2463 Posted July 30, 2008 Share Posted July 30, 2008 Have a look <a href="http://uk.php.net/manual/en/function.ob-flush.php"> Here at ob_flush()</a> Link to comment https://forums.phpfreaks.com/topic/117372-solved-ftp-progress/#findComment-603691 Share on other sites More sharing options...
next Posted July 30, 2008 Author Share Posted July 30, 2008 Nice, thank you! Link to comment https://forums.phpfreaks.com/topic/117372-solved-ftp-progress/#findComment-603711 Share on other sites More sharing options...
sernita Posted September 9, 2008 Share Posted September 9, 2008 Hi, next, Can you write the solution, please? I'm trying to do the same. Thanks! Link to comment https://forums.phpfreaks.com/topic/117372-solved-ftp-progress/#findComment-637401 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.