3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\ProgressBar\Upload
;
12 use Zend\ProgressBar\Exception
;
15 * Progress Bar Upload Handler for the UploadProgress extension
17 class UploadProgress
extends AbstractUploadHandler
22 * @throws Exception\PhpEnvironmentException
24 protected function getUploadProgress($id)
26 if (! $this->isUploadProgressAvailable()) {
27 throw new Exception\
PhpEnvironmentException(
28 'UploadProgress extension is not installed'
32 $uploadInfo = uploadprogress_get_info($id);
33 if (! is_array($uploadInfo)) {
44 $status = $uploadInfo +
$status;
45 $status['total'] = $status['bytes_total'];
46 $status['current'] = $status['bytes_uploaded'];
47 $status['rate'] = $status['speed_average'];
48 if ($status['total'] == $status['current']) {
49 $status['done'] = true;
56 * Checks for the UploadProgress extension
60 public function isUploadProgressAvailable()
62 return is_callable('uploadprogress_get_info');