title: PHP Display a percentage of progress of ftp_get?
body: <p>I have a working FTP file download script.<br>
  The files I am downloading will be about 2-4 GB per day.<br>
  I was wondering if there was a way to get the percent of the file where it's at?</p>
  
  <p>I have looked on php.net and on here but I couldn't find any similar questions and rather spend more time looking I figure I would ask people much smarter than myself.</p>
  
  <p>I was thinking about if there was a function to see where it's at in the download, but I couldn't find one since <code>ftp_get</code> would have to complete first so that eliminated the chance of flushing the buffer every few seconds to display a new percent.</p>
  
  <p>Anyone?</p>
  
  <p>Here is my code: I hid all of my variables above it.</p>
  
  <pre><code>$conn_id = ftp_connect($ftp_server);
  
  $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
  
  if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
      echo "Successfully written to $local_file\n";
  } else {
      echo "There was a problem\n";
  }
  
  ftp_close($conn_id);
  </code></pre>
  
  <hr>
  
  <p>EDIT:</p>
  
  <p>I added <code>ftp_nb_get</code> and here is my code for that. It keeps downloading fine, just doesn't echo it out to the browser.</p>
  
  <pre><code>$ret = ftp_nb_get($conn_id, $local_file, $server_file, FTP_BINARY, $size);
  while ($ret == FTP_MOREDATA) {
    echo round((filesize($local_file)/$server_size)*100)."%\n";
    $ret = ftp_nb_continue($conn_id);
  }
  </code></pre>