onBeforeFileAdd

fires the moment you try to add file to uploader

boolean onBeforeFileAdd(object file);
fileobjectan object with the file data
booleanreturning false will prevent further processing of a file

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 (number) - the file ID generated automatically with the webix.uid() method per each uploading session
  • name (string) - the file title and extension
  • file (object) - File object
  • percent (number) - the indicator of the loading progress
  • size (number) - the size of the file in bytes (as a number)
  • sizetext (string) - the size of the file as a string, like "522Kb"
  • sname (string) - the file name under which it was saved on server
  • status (string) - 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 (string) - the file extension.

If the method returns false further processing of a file (i.e. adding it to the client-side storage and uploading) will be blocked.

See also
Back to top
Join Our Forum
We've retired comments here. Visit our forum for faster technical support, connect with other developers, and share your feedback there.