I want to make use of upload_progress session introduced in PHP 5.4. But I can't get any result.
Here is my form:
<form enctype="formdata/multipart">
<input type="hidden" id='prog' value='test' name="<?php echo ini_get("session.upload_progress.name"); ?>">
<label>Upload Your Files</label><br />
<input name="file" type="file" id="file"><br />
<input name="send" value="Upload!" id="uploadButton" type="submit" />
<br />
</form>
And here is my Javascript:
sub.addEventListener("click", function(event){
event.preventDefault();
event.stopPropagation();
formData.append("file", file.files[0]);
var http = new XMLHttpRequest();
http.open("POST", "upload.php");
http.setRequestHeader("Cache-Control", "no-cache");
http.addEventListener("load", function(){
console.log("Finished.");
}, false);
var myprogfield = document.getElementById("prog");
formData.append(myprogfield.getAttribute("name"), myprogfield.value);
http.send(formData);
setInterval(function(){
var http = new XMLHttpRequest();
http.open("GET", "progress.php");
http.send(null);
}, 500);
}, false);
As you can see, I use the following to send a request to progress.php to get a result from it.
setInterval(function(){
var http = new XMLHttpRequest();
http.open("GET", "progress.php");
http.send(null);
}, 500);
Here is progress.php, I echo()
the whole $_SESSION
each time to get all values of $_SESSION, but each time it sends it null.
<?php
session_start();
var_dump($_SESSION);