- In the extension bar, click the AdBlock Plus icon
- Click the large blue toggle for this website
- Click refresh
- In the extension bar, click the AdBlock icon
- Under "Pause on this site" click "Always"
- In the extension bar, click on the Adguard icon
- Click on the large green toggle for this website
- In the extension bar, click on the Ad Remover icon
- Click "Disable on This Website"
- In the extension bar, click on the orange lion icon
- Click the toggle on the top right, shifting from "Up" to "Down"
- In the extension bar, click on the Ghostery icon
- Click the "Anti-Tracking" shield so it says "Off"
- Click the "Ad-Blocking" stop sign so it says "Off"
- Refresh the page
- In the extension bar, click on the uBlock Origin icon
- Click on the big, blue power button
- Refresh the page
- In the extension bar, click on the uBlock icon
- Click on the big, blue power button
- Refresh the page
- In the extension bar, click on the UltraBlock icon
- Check the "Disable UltraBlock" checkbox
- Please disable your Ad Blocker
- Disable any DNS blocking tools such as AdGuardDNS or NextDNS
- Disable any privacy or tracking protection extensions such as Firefox Enhanced Tracking Protection or DuckDuckGo Privacy.
If the prompt is still appearing, please disable any tools or services you are using that block internet ads (e.g. DNS Servers, tracking protection or privacy extensions).
Question
Jayzee
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.
[size=5]2. Second, the file structure....[/size]
[size=5]3. The content...[/size]
[b]index.php:[/b]
<?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]
<?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]
<?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
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.
Link to comment
https://www.neowin.net/forum/topic/1063478-php-540-upload-tracking-returning-empty-array/Share on other sites
3 answers to this question
Recommended Posts