Source of file UploadProgress.php
Size: 1,724 Bytes - Last Modified: 2014-03-12T23:21:18+01:00
/home/theseer/Downloads/ZendFramework-2.3.0/library/Zend/ProgressBar/Upload/UploadProgress.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 | <?php /** * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace Zend\ProgressBar\Upload; use Zend\ProgressBar\Exception; /** * Progress Bar Upload Handler for the UploadProgress extension */ class UploadProgress extends AbstractUploadHandler { /** * @param string $id * @return array|bool * @throws Exception\PhpEnvironmentException */ protected function getUploadProgress($id) { if (!$this->isUploadProgressAvailable()) { throw new Exception\PhpEnvironmentException( 'UploadProgress extension is not installed' ); } $uploadInfo = uploadprogress_get_info($id); if (!is_array($uploadInfo)) { return false; } $status = array( 'total' => 0, 'current' => 0, 'rate' => 0, 'message' => '', 'done' => false ); $status = $uploadInfo + $status; $status['total'] = $status['bytes_total']; $status['current'] = $status['bytes_uploaded']; $status['rate'] = $status['speed_average']; if ($status['total'] == $status['current']) { $status['done'] = true; } return $status; } /** * Checks for the UploadProgress extension * * @return bool */ public function isUploadProgressAvailable() { return is_callable('uploadprogress_get_info'); } } |