Class nextdb.html.FileUpload
Object
|
+--nextdb.html.FileUpload
- class
nextdb.html.FileUpload
FileUpload is used to dynamically post a file to the server. There
are tow callback functions associated with the function, one for the beginning
of the file transmission to the server and one for when the upload is complete.
The second callback is passed a reference URL that can be used to insert the file
into a table/column of choice.
// the file uploader is constructed with a connection instance,
// the name of the table for the insert and two callback functions.
// The first callback is fired when the upload starts allowing you
// to activate some progress indicator. The second callback is
// passed a URL when the file has been loaded. You still need to
// execute your insert inside the second callback function, you
// use the URL for the insert into the binary column.
var uploader = new nextdb.html.FileUpload(conn,"USER_PIC",
function(){
// start loading
document.getElementById("uploadprogress").style.display="block";
},
function(url){
// end loading
document.getElementById("uploadprogress").style.display="none";
var insert = new nextdb.Insert("PIC");
insert.map["pic"]=url;
conn.executeInsert(insert, function(key,error){
if(error)
alert(error.getMessage());
else{
$("pic").src=url;
}
}
);
}, function(progress){
// if supplied this function is passed
// a progress indicator every 100 milliseconds
var uploadedBytes = progress.rx;
var totalBytes = progress.totalRX;
var perct = (Math.round((uploadedBytes/totalBytes)*100))+"%";
}
)
document.getElementById("uploader").appendChild(uploader.getElement());
Defined in api.docs.js
nextdb.html.FileUpload
nextdb.html.FileUpload(<nextdb.Connection> conn,<String> table,<function> callbackStart,<function> callbackFinish,<function> callbackProgress)
Parameters:
table - (name of the table this file is to be associated with)
callbackStart - indicates the start of the file upload
callbackFinish - indicates that the upload is complete and returns the URL to the image that you use in the insert
callbackProgress - optional callback to indicate the real upload progress to the user, it is passed an object with field rx for uploaded bytes and totalRX for the total number of bytes.
addClassName
void addClassName(className)
getElement
HTMLElement getElement()
Documentation generated by
JSDoc on Fri Apr 1 10:54:23 2011