Commits

christiansalazar committed 57c91fe

controlling file uploads (client-side)

Comments (0)

Files changed (2)

 	public $receptorClassName;
 	public $methodName;
 	public $userdata;
+	public $multipleFileSelection=true; // true or false. allow the user to select multiple files at once.
+	public $maxConnections=3; // max simultaneus connections (client-side)
+	public $maxUploads=-1; // -1=unlimited. number of uploads allowed (client-side)
+	public $maxUploadsReachMessage = ''; // a message when maxUploads is reach.
 
 	private $_baseUrl;
 
 				'dropFilesText'=>$this->dropFilesText,
 				'uploaderContainer'=>$upid,
 				'sizeLimit'=>$this->sizeLimit, // for client-side size validt.
+				'multipleFileSelection'=>$this->multipleFileSelection,
+				'maxConnections'=>$this->maxConnections,
+				'maxUploads'=>$this->maxUploads,
+				'maxUploadsReachMessage'=>$this->maxUploadsReachMessage,
 				//'data'=>serialize($vars),
 			)
 		);

assets/cocowidget.js

 
 	}
 
+	this.onSubmit = function(id, filename){
+		if(options.maxUploads == -1){
+			return true;
+		}else
+			if(id >= options.maxUploads){
+				if(options.onMessage != null)
+					if(options.maxUploadsReachMessage != '')
+						options.onMessage(options.maxUploadsReachMessage);
+				return false;
+			}
+			else
+				return true;
+	}
+
 	this.run = function(){
 		var _this = this;
 		var _uploader = new qq.FileUploader({
+			maxConnections: options.maxConnections, // max simultaneous
+			multiple: options.multipleFileSelection, // user file selection
 			sizeLimit: options.sizeLimit,	// client side size validation
 			buttonText: options.buttonText,
 			dropFilesText: options.dropFilesText,
 			action: options.action,
 			onComplete: _this.onComplete,
 			onCancel: _this.onCancel,
+			onSubmit: _this.onSubmit,// helps controlling the number of uploads
 			showMessage: _this.showMessage
 		});
 	}