onBeforeFileAdd

fires the moment you try to add file to uploader

void onBeforeFileAdd(object file){ ... };

Parameters

fileobjectan object with the file data

Example

$$("uploader_1").attachEvent("onBeforeFileAdd", function(file){
    var type = file.type.toLowerCase();
    if (type != "jpg" && type != "png"){
        webix.message("Only PNG or JPG images are supported");
        return false;
    }
});

Related samples

Details

The file object contains the following properties:

  • id - the file ID generated automatically with the webix.uid() method per each uploading session;
  • name - the file title and extension;
  • percent - the indicator of the loading progress;
  • size - the size of the file in bytes (as a number);
  • sizetext - the size of the file as a string, like "522Kb";
  • sname - the file name under which it was saved on server;
  • status - the upload status that changes during uploading:
    • "client" - the file is added to the uploader body on the client side, the uploading hasn't been started yet or was aborted by a user;
    • "transfer" - the file uploading is in progress;
    • "server" - the file has been successfully uploaded;
    • "error" - an error occurred during uploading.
  • type - the file extension.
See also
Back to top