I’m wondering if my solution to receiving progress indication of an upload would work, and if it’s possible, am I going about it the right way? It doesn’t have to be really accurate, I just want a little more than a spinning, animated icon.
1) On upload form page ////////
Submit upload form & files to processing page.
2) On processing page /////////
For Each file In myFileArray Then
' Save the file
' Add 1 to a cookie called progressReport
Next
3) On upload form page ///////
checkTimer = window.setInterval(function () {
var cookieContents = $.cookie('progressReport');
if (cookieContents != "")
$('#uploadProgress').html(cookieContents + ' files uploaded');
}, 2000);
—- UPDATE —-
Thanks to a below answer, I cannot accomplish this because the cookie would not get written until the page finished processing – meaning the user wouldn’t get any feedback until it had finished. Useless!
I’ve changed my plan. This suits my application, probably not to some.
1) Make AJAX call to server page that creates a unique ID and a folder named, ‘unique ID’. When done, send ID back as response, add unique ID to hidden input in upload form.
2) User submits file(s), check ID is present in hidden input, then post to a hidden iFrame. On submission, make an AJAX call to another server page every 1-5 seconds, checking how many files are in that folder, send quantity back as response, update progress panel.
It won’t work because this:
Will not write the cookie to the browser until all the files are finished.
You need to devise a way to start uploading these files one by one from the client side. Your processing page receives only one file; increments the value in the cookie and finishes the response. In other words, your processing page ends up being called n times for n files. Your javascript code keeps reading the cookie every 2 seconds and displaying the value that was updated by the last response.