I am trying to create an upload progress bar with PHP. I saw the new feature of PHP 5.4: upload progress session.
This is my HTML code:
It's not possible in one POST request, you can do AJAX requests, and read session while file is uploading. After file is uploaded, the session.upload_progress.name
key is removed so you are getting an empty array.
I think it's because your form is not getting submitted, as you have return false in
$('#upload').submit(function () {
interval_id = setInterval(function () {
$.ajax({
url: "ajax/progress.php6",
type: "POST",
success: function (data) {
console.log(data);
}
});
}, 200);
return false;
});
and it initializes interval, so the page always return null as nothing is being uploaded. Try using http://www.malsup.com/jquery/form, it submits form
Wasn't able to sort it out so I used XMLHTTPREQUEST "progress" action and that worked well. Thanks!