Jump to content


[PHP 5.4.0] Upload tracking returning empty array

  • Please log in to reply
3 replies to this topic

#1 Jayzee


    Underground coder

  • Joined: 27-August 04
  • Location: Inside of DS register

Posted 11 March 2012 - 07:30

I'm using the latest PHP 5.4.0 and was considering switching from using nginx upload tracking extension to now PHP native upload tracking. The problem is - session returns empty array (yes, I tried uploading huge files and the server is _not_ running on my development machine)! The everything _should_ be set up by-the-book and I have analyzed all available tutorials to no avail. Can anyone help?

1. Is upload enabled in your php.ini? Yes.

session.upload_progress.enabled = On
session.upload_progress.cleanup = On
session.upload_progress.prefix = "upload_progress_"
session.upload_progress.name = "PHP_SESSION_UPLOAD_PROGRESS"
session.upload_progress.freq =  "1%"
session.upload_progress.min_freq = "1"

2. Second, the file structure....


3. The content...


$key = ini_get("session.upload_progress.name");
<!doctype html>
  <title>Upload test</title>
<h3>Select multiple files</h3>
<form name="uploadForm" id="uploadForm" target="uploadIframe" action="upload.php" enctype="multipart/form-data" method="post">
<input type="hidden" name="<?=$key; ?>" id="key" value="123" />
<input id="uploadButton" type="file" name="uploads[]" accept="image/bmp, image/gif, image/jpeg, mage/pipeg, image/pjpeg, image/png, image/x-png, image/tiff" multiple />
<iframe name="uploadIframe" id="uploadIframe" width="0" height="0" frameborder="0" border="0" src="about:blank"></iframe>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
  var timer;
  function progress_fetch() {
	$.getJSON("progress.php", function(data) {
	  if (data == "done")
  $(document).ready(function() {
  $("#uploadForm").change(function() {
  // start polling the progress code
  timer = setInterval("progress_fetch()", 1000);


$key = ini_get("session.upload_progress.prefix") . "123";
if (!empty($_SESSION[$key]))
  $answer = print_r($_SESSION[$key], 1);
  $answer = "done";
  echo json_encode($answer);


header("Content-Type: text/plain");
$uploadFolder = "upload/";
$loopCounter = 0;
$response = array();
foreach ($_FILES['uploads']['tmp_name'] as $uploadSource)
  $uploadDestination = 'upload/' . basename($_FILES['uploads']['name'][$loopCounter]);
  if (is_uploaded_file($uploadSource))
    move_uploaded_file($uploadSource, $uploadDestination);
    $fileArray = array(
	 "name" => $_FILES['uploads']['name'][$loopCounter],
	 "size" => $_FILES['uploads']['size'][$loopCounter],
	 "path" => $uploadDestination
   array_push($response, $fileArray);
echo json_encode($response);

Running my test code (see above) I only see
array(0) {
in javascript console instead of array containing uploaded file data. FYI, upload.php is first called when all data has been uploaded.

#2 wil



  • Joined: 01-October 05

Posted 21 March 2012 - 16:53


found the cause of the problem

$key = ini_get("session.upload_progress.name");

returns false for me

which points me to http://php.net/manua...ion.ini-get.php
suggesting session.upload_progress.name configuration doesn't exist

#3 Serkan Bulutgenç

Serkan Bulutgenç

    Resident One Post Wonder

  • Joined: 24-March 13

Posted 24 March 2013 - 21:37

Hi.. I had same problem but I've just solved. Actually sessions are not empty but due to session.upload_progress.clean=on in your ini file, they're cleaning.İf you change this setting off you'll see the session values..

#4 geraldine


    Resident One Post Wonder

  • Joined: 12-July 14

Posted 12 July 2014 - 12:04

In some cases I have the same problem despite session.upload_progress.cleanup=off. For small files (MB) it works rather nicely. But as soon as trying to upload files with size around 6-7 GB or larger the session key gets empty. Does anybody know a solution for this?