NextDB.net

Class net.nextdb.html.FileUpload

Object
   |
   +--net.nextdb.html.FileUpload

class net.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 net.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 net.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
net.nextdb.html.FileUpload(<net.nextdb.Connection> conn,<String> table,<function> callbackStart,<function> callbackFinish,<function> callbackProgress)
           
 
Method Summary
 void addClassName(className)
          
 HTMLElement getElement()
          

Constructor Detail

net.nextdb.html.FileUpload

net.nextdb.html.FileUpload(<net.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 Mon Mar 29 20:15:50 2010