You are here

function filefield_source_remote_progress in FileField Sources 6

Same name and namespace in other branches
  1. 7 sources/remote.inc \filefield_source_remote_progress()

Menu callback; progress.js callback to return upload progress.

1 string reference to 'filefield_source_remote_progress'
filefield_source_remote_menu in sources/remote.inc
Implements hook_menu().

File

sources/remote.inc, line 273
A FileField extension to allow referencing of existing files.

Code

function filefield_source_remote_progress($type_name, $field_name, $delta) {
  $key = $type_name . '_' . $field_name . '_' . $delta;
  $progress = array(
    'message' => t('Starting transfer...'),
    'percentage' => -1,
  );
  if ($cache = cache_get('filefield_transfer:' . session_id() . ':' . $key)) {
    $current = $cache->data['current'];
    $total = $cache->data['total'];
    $progress['message'] = t('Transferring... (@current of @total)', array(
      '@current' => format_size($current),
      '@total' => format_size($total),
    ));
    $progress['percentage'] = round(100 * $current / $total);
  }
  drupal_json($progress);
}