ExUpload An easy extension to upload files through Explorer

Get Ready

Server Data

Your server should return an ID for the file you are uploading. If you are not going to save the uploaded in a database, you can set "useAutomaticId" to true (see below) and ExUpload will handle this for you. ExUpload expects an JSON object like this {id: 0}.

Attributes

Params {params}


<<<<<<< HEAD

I am going to explain only params atttribute since it is the only one which was not clearly explained above.
So, params is a JSON object which must have an attribute called 'fileParam'. It will have the param name of the file you are uploading. It's default value is 'file'. =======

'Params' is a JSON object which must have an attribute called 'fileParam'. It will have the param name of the file you are uploading. It's default value is 'file'. >>>>>>> fd37679154e6cb3c691a2b24f4a6a1f7866a4757 You can pass as much params as you want.
You can do it like this: var params = {"fileParam": "myCustomParamName", "param1":"value", "param2": "value", "paramN": "valueN"};


UseAutomaticId exUpload.useAutomaticId


If your server is not going to return an id for the uploaded file, you must set this attribute to true, otherwise ExUpload will throw an error. This flag basically will tell ExUpload to create a random ID for each file you have uploaded. Remember, Explorer will not add a file that does not have an ID.

Callback Callback(data, success)

This function will be called after each upload get done or if something get wrong while uploading the file. You must create a function with two parameters, the first one will be the response from your server, and the second will be true if everything works fine, otherwise, false. If you do not set any function ExUpload will still work.

Valid File Types

ExUpload will look for valid extensions at ExplorerIcons.css. The css class names will identify the valid files. For example, if you want to let people upload .jpg files on your web site, you must add a class called .jpg in ExplorerIcons and set its icon. If you do not have an icon at the moment you can create the class like this ._jpg and ExUpload will put an default icon on these files. By default Explorer already allow some files, but if you do not want to let them being uploaded, you should comment, remove or so the lines with the class names of those files.

Didn't you like ExUpload default validation? Sure, you can add your own

You can set an array of valid extensions to ExUpload. Thus, it will not check ExplorerIcons.css. It is really simple, just do as show below: <<<<<<< HEAD


=======


>>>>>>> fd37679154e6cb3c691a2b24f4a6a1f7866a4757
  1. var explorer = new Explorer();
  2. var exUpload = new ExUpload ( explorer, "/foo/upload.php", {params});//params is not required. Its default value is 'file'. However, if your server is expecting a different parameter, you must set it through the third parameter.
  3. exUpload.allowedExtensions = ["png", "jpg"];
  4. exUpload.start();

If an invalid file has been sent, ExUpload will call your callback function passing an object with a message and the following error code ERROR_INVALID_FILE. So, if you want to check if the throwed error is about invalid file type, just write a condition inside your callback function checking if data.error is equal to notify.ERROR_INVALID_FILE.