So, I used this file upload method a bit, but it seems that Google Gears does not support new browsers that implement the HTML5 specifications poorly. I heard the word deprecated , floating across multiple channels, so I'm looking for a replacement that can perform the following tasks and support new browsers. I can always go back to the transmissions / standard POST files, but these following elements simplify my process:
- Users MUST be able to select multiple files to upload in the dialog box.
- I MUST be able to receive status updates when transferring a file. (progress indicators)
- I would like to use
PUT requests instead of POST - I would like to be able to easily attach these events to existing HTML elements using JavaScript. I.E. file selection should be activated by pressing
<button> . - I would like to easily manage response / request parameters using JavaScript.
I'm not sure if the new HTML5 browsers have support for object / query engines, or if there is a flash loader that has these features that I miss in my Google searches.
An example of loading code using gears:
// select some files: var desktop = google.gears.factory.create('beta.desktop'); desktop.openFiles(selectFilesCallback); function selectFilesCallback(files) { $.each(files,function(k,file) { // this code actually goes through a queue, and creates some status bars // but it is unimportant to show here... sendFile(file); }); } function sendFile(file) { google.gears.factory.create('beta.httprequest'); request.open('PUT', upl.url); request.setRequestHeader('filename', file.name); request.upload.onprogress = function(e) { // gives me % status updates... allows e.loaded/e.total }; request.onreadystatechange = function() { if (request.readyState == 4) { // completed the upload! } }; request.send(file.blob); return request; }
Edit: Apparently, flash is not able to use PUT requests, so I changed it to "how" and not to "must".
javascript html flash file-upload google-gears
gnarf
source share