NextDB.net

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


Constructor Summary
nextdb.html.FileUpload(<nextdb.Connection> conn,<String> table,<function> callbackStart,<function> callbackFinish,<function> callbackProgress)
           
 
Method Summary
 void addClassName(className)
          
 HTMLElement getElement()
          

Constructor Detail

nextdb.html.FileUpload

nextdb.html.FileUpload(<nextdb.Connection> conn,<String> table,<function> callbackStart,<function> callbackFinish,<function> callbackProgress)

Method Detail

addClassName

void addClassName(className)

getElement

HTMLElement getElement()

NextDB.net

Documentation generated by JSDoc on Fri Apr 1 10:54:23 2011