class SAPO.Component.AjaxUpload
Authors:
jose.p.dias AT co.sapo.pt
 TODO: IE6-8 compatibility!
 can't get response body so far...
 iframe is visible is ie8 too :P



 requires SAPO.Dom.Event



 This component makes it possible to upload files behind the scenes.

 Given the elem, it is populated with a form with a visible file selector.

 Once the user is ready to submit the form along with optional additional arguments,
 the send method must be invoked.

 Once to roundtrip has been done, the onResult callback is invoked.
 If an error occurred, err is filled, otherwise one can get the debug params back from the server.

 Two optional additional callbacks are supported:
 - onFileSet, which is triggered once the uses chooses a file.
 - onStart, which is triggered when the data upload begins.
   This can be useful for setting visual queues of the workflow status.
 
Version:
2.1
Since:
November 2011
Defined in Component/AjaxUpload/2.1/lib.js

Constructor Summary
AjaxUpload (String|DomElement elem, Object options)

Function Summary
send (Object data)
- sends the given data along with the file the user must have already chosen

Constructor Details

constructor AjaxUpload

AjaxUpload(String|DomElement elem, Object options)
Parameters:
elem
options
  • String endpoint - URI
  • String fileFiledName - field which will carry the file
  • Function(err, data, instance) onResult - if err is filled, upload failed. data is for debugging purposes. instance is the AjaxUpload which made the uplaod possible
  • [ Function(fn, instance) onFileSet ] - file name set by the user (path is stripped).
  • [ Function(fn, instance) onStart ] - file name set by the user (path is stripped).

Function Details

function send

send(Object data)
- sends the given data along with the file the user must have already chosen
Parameters:
data - each key/value pair is sent as a hidden form field.