file uploads and progress monitoring on on-rev(reposted )

Andre Garzia andre at andregarzia.com
Mon Nov 29 12:18:02 EST 2010


Martin

The problem is not checking the amount of bytes that arrived, this is easy.
The hard part is informing back the browser and updating the web page. When
you click "upload" the browser will stop receiving communication from the
server such as xmlHTTPRequests and process your upload order. The only way
is change this behaviour is by throwing javascript into the problem to
hijack the upload request and process it "by hand" with websockets or hidden
iframe so that your main web page still responsive and can still pool the
server for progress update while something is happening. This involves
changing the code on the server and on the client-side. The workflow is like
this:

1 - User wants to upload a file
2 - javascript intercepts this order
3 - javascript requests a token from server for an upload job
4 - javascript saves token to memory
5 - javascript uses hidden iframe or similar solution to upload file passing
along the token
6 - server receives token and starts to receive file, saves progress for
token somewhere
7 - javascript uses asynchronous request at some interval to pool the server
asking for progress using the token to identify itself
8 - javascript picks the progress and update web page repeating step 7 till
progress is complete

again, non-trivial but can be done. The issue is not on the server but on
the web browser... web browsers are kinda stupid.

-- 
http://www.andregarzia.com All We Do Is Code.



More information about the use-livecode mailing list