• 0

[PHP 5.4.0] Upload tracking returning empty array


Question

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"
[/CODE]

[size=5]2. Second, the file structure....[/size]

post-68837-0-46299900-1331450128.png

[size=5]3. The content...[/size]

[b]index.php:[/b]

[CODE]
<?php
session_start();
$key = ini_get("session.upload_progress.name");
?>
<!doctype html>
<html>
<head>
<title>Upload test</title>
</head>
<body>
<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 />
</form>
<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")
clearInterval(timer);
else
console.log(data);
});
}
$(document).ready(function() {
$("#uploadForm").change(function() {
$(this).submit();
// start polling the progress code
timer = setInterval("progress_fetch()", 1000);
});
});
</script>
</body>
</html>
[/CODE]

[b]progress.php:[/b]

[CODE]
<?php
session_start();
$key = ini_get("session.upload_progress.prefix") . "123";
if (!empty($_SESSION[$key]))
$answer = print_r($_SESSION[$key], 1);
else
$answer = "done";
echo json_encode($answer);
?>
[/CODE]

[b]upload.php:[/b]

[CODE]
<?php
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);
}
$loopCounter++;
}
echo json_encode($response);
?>
[/CODE]

Running my test code (see above) I only see

[CODE]
array(0) {
}
[/CODE]

in javascript console instead of array containing uploaded file data. FYI, upload.php is first called when all data has been uploaded.

3 answers to this question

Recommended Posts

  • 0

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?

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • It's significant growth for Linux considering the market share, so it could have had that effect I described.
    • Microsoft and Crowdstrike announce partnership on threat actor naming by Pradeep Viswanathan Whenever a cyberattack is discovered, companies disclose it to the public and assign it a unique name based on their internal procedures. Unfortunately, this leads to inconsistencies, as each company has its own naming conventions. As a result, the same threat actor behind a cyberattack may end up with multiple names, causing delays and confusion in response efforts. For example, a threat actor that Microsoft refers to as Midnight Blizzard might be known as Cozy Bear, APT29, or UNC2452 by other security vendors. To address this issue, Microsoft and CrowdStrike are teaming up. These companies will align their individual threat actor taxonomies to help security professionals respond to cyberattacks with greater clarity and confidence. It’s important to note that Microsoft and CrowdStrike are not attempting to create a single naming standard. Instead, they are releasing a mapping that lists common threat actors tracked by both companies, matched according to their respective taxonomies. The mapping also includes corresponding aliases from each group’s naming system. You can view the joint threat actor mapping by Microsoft and CrowdStrike here. Although this threat actor taxonomy mapping is a joint effort between Microsoft and CrowdStrike, Google/Mandiant and Palo Alto Networks' Unit 42 are expected to contribute to this initiative in the future. Vasu Jakkal, Corporate Vice President of Microsoft Security, wrote the following about this collaboration with CrowdStrike: As more organizations join this initiative, the collective defense against cyber threats will undoubtedly be improved.
    • You make no sense since most of the stuff on YouTube is free to begin with. Comparing Netflix to YouTube is not even remotely the same. YouTube has tons of free videos to begin with, unlike Netflix, you are paying Netflix for original style of programming.
    • Youtube can go screw themselves. Never ever, ever will I pay for this BS nonsense. And I encourage anyone else not to either.
  • Recent Achievements

    • Week One Done
      Nullun earned a badge
      Week One Done
    • First Post
      sultangris earned a badge
      First Post
    • Reacting Well
      sultangris earned a badge
      Reacting Well
    • First Post
      ClarkB earned a badge
      First Post
    • Week One Done
      Epaminombas earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      172
    2. 2
      ATLien_0
      125
    3. 3
      snowy owl
      122
    4. 4
      Xenon
      116
    5. 5
      +Edouard
      93
  • Tell a friend

    Love Neowin? Tell a friend!