file_ajax_progress
function file_ajax_progress
file_ajax_progress($key)
Menu callback for upload progress.
Parameters
$key: The unique key for this upload process.
File
- modules/file/file.module, line 297
- Defines a "managed_file" Form API field and a "file" field for Field module.
Code
function file_ajax_progress($key) { $progress = array( 'message' => t('Starting upload...'), 'percentage' => -1, ); $implementation = file_progress_implementation(); if ($implementation == 'uploadprogress') { $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']); } } elseif ($implementation == 'apc') { $status = apc_fetch('upload_' . $key); if (isset($status['current']) && !empty($status['total'])) { $progress['message'] = t('Uploading... (@current of @total)', array('@current' => format_size($status['current']), '@total' => format_size($status['total']))); $progress['percentage'] = round(100 * $status['current'] / $status['total']); } } drupal_json_output($progress); }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!file!file.module/function/file_ajax_progress/7.x