When uploadprogress extension is available, besides a percent, it is possible to display the following information with the progress bar.

- Elapsed time.
- Time left.
- Speed in size units per second.

It could look like this:

filefield_uploadprogress.png

I have implemented this using a custom module for a project I'm working on, but maybe it could be included in filefield module, it just requires a few lines added to filefield.module.

     $status = uploadprogress_get_info($key);
     if (isset($status['bytes_uploaded']) && !empty($status['bytes_total'])) {
       $progress['message'] = t('Uploading... (@current of @total)', array('@current' => format_size($status['bytes_uploaded']), '@total' => format_size($status['bytes_total'])));
       $progress['percentage'] = round(100 * $status['bytes_uploaded'] / $status['bytes_total']);
+
+      $extra = array();
+      if (!empty($status['time_start']) && !empty($status['time_last'])) {
+        $extra[] = t('Elapsed time: @time', array('@time' => filefield_format_elapsed($status['time_last'] - $status['time_start'])));
+      }
+      if (!empty($status['est_sec'])) {
+        $extra[] = t('Time left: @time', array('@time' => filefield_format_elapsed($status['est_sec'])));
+      }
+      if (!empty($status['speed_average'])) {
+        $extra[] = t('Speed: @size/sec', array('@size' => format_size($status['speed_average'])));
+      }
+      if (!empty($extra)) {
+        $progress['message'] .= '<br />' . implode(', ', $extra);
+      }
     }
/**
 * Format elapsed time.
 */
function filefield_format_elapsed($seconds) {
  if ($seconds < 60) {
    return '00:00:' . sprintf('%02d', $seconds);
  }

  $minutes = ceil($seconds / 60);
  $seconds = $seconds % 60;
  if ($minutes < 60) {
    return '00:' . sprintf('%02d', $minutes) . ':' . sprintf('%02d', $seconds);
  }

  $hours = ceil($minutes / 60);
  $minutes = $minutes % 60;
  return sprintf('%02d', $hours) . ':' . sprintf('%02d', $minutes) . ':' . sprintf('%02d', $seconds);
}

Cheers

CommentFileSizeAuthor
filefield_uploadprogress.png9.71 KBmarkus_petrux

Comments

quicksketch’s picture

Status: Needs review » Postponed

Hey @markus_petrux, thanks for the suggestion. At this point I don't think we're going to be making any feature additions to FileField, with the exception of backports from D8/D7.

It would make sense IMO if the progress information was passed through the theme system so such changes could be added individually without modifying FileField. That would make a good enhancement for both FileField (D6) and File module (D7+).

quicksketch’s picture

Additionally, my personal opinion is that adding more information is more noise than it is actually helpful, which is why I'd like to see it be extensible rather than having it display all the information by default.

pwolanin’s picture

Status: Postponed » Closed (won't fix)

bug fixes only