Data files are uploaded and processed by my web app which take anywhere from a few seconds to several minutes to finish depending on their size. I’d like to provide feedback to the user that the file is still processing and show its progress every few hundred records. If I can push multiple messages to the browser while in the processing loop, this should suffice.
Does anyone know a simple way of doing this?
Implementing comet or ajax push engine for this seems like overkill and would probably require more effort than it would be worth.
One thought I had was to use an ajax submit button but it won’t work with activeFileField.
So the status is not about the upload progress of a file but about the status of an asynchronous process on the server side (e.g.: updating a lot of rows via a cron job etc.)? A hacky solution could be to short poll a script with an interval of around 3-4 seconds. The action on the server side would return the status of the process as saved in a cached variable (via memcached, APC, or filecache). The process doing the asynchronous processing could then update this cache variable each 100 records as you said.
Right; it’s not about the file upload itself but the processing afterwards. For the browser to periodically poll for progress, I’d need to make the processing loop store the incremental progress for that specific upload somewhere which would be feasible but inelegant. I’m trying to avoid polling and explore other possibilities.
Hm, I don’t know any other way than comet otherwise. If you are using nginx these two modules could be of interest. I used the push stream module myself and it is easy to set up:
nginx push module
nginx push stream module
hope it helps a bit,