Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'feature/form-upload-progress' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/Upload/SessionProgress.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ protected function getUploadProgress($id)
);
}

$uploadInfo = $_SESSION[ini_get('session.upload_progress.prefix') . $id];
$sessionKey = ini_get('session.upload_progress.prefix') . $id;
$uploadInfo = (isset($_SESSION[$sessionKey])) ? $_SESSION[$sessionKey] : null;
if (!is_array($uploadInfo)) {
return false;
}
Expand All @@ -45,12 +46,15 @@ protected function getUploadProgress($id)
'current' => 0,
'rate' => 0,
'message' => '',
'done' => false
'done' => false,
);
$status = $uploadInfo + $status;
$status['total'] = $status['content_length'];
$status['current'] = $status['bytes_processed'];
$status['rate'] = $status['bytes_processed'] / (time() - $status['start_time']);

$time = time() - $status['start_time'];
$status['rate'] = ($time > 0) ? $status['bytes_processed'] / $time : 0;

if (!empty($status['cancel_upload'])) {
$status['done'] = true;
$status['message'] = 'The upload has been canceled';
Expand All @@ -66,7 +70,6 @@ protected function getUploadProgress($id)
*/
public function isSessionUploadProgressAvailable()
{
return (bool) version_compare(PHP_VERSION, '5.4.0rc1', '>=')
&& (bool) ini_get('session.upload_progress.enabled');
return (bool) ini_get('session.upload_progress.enabled');
}
}

0 comments on commit 3bb86fe

Please sign in to comment.