Check documentation for the latest version of dhtmlxSuite onBeforeFileAdd DHTMLX Docs


fires before the user adds a file to the upload queue

void onBeforeFileAdd(object file);
fileobjectan object with file details


myVault.attachEvent("onBeforeFileAdd", function(file){  
    // file is an object with details
        id:                 123,         // number, internal file ID
        name:               "fname.ext", // string, filename detected by browser
        lastModifiedDate:   Date,        // date object if retrieved (1)
        size:               132500,      // number, file size in bytes
        uploaded:           true,        // boolean, true/false
        error:              false        // boolean, error while uploading (if any)
    // your code here, for example
    if (file.size > 1234567) return false;    
    return true;   


This API page is for Vault v2.5. Please go to to see API reference for the current version of dhtmlxVault.

  • cancelable, return false to cancel the 'add' operation
  • this event can be used to filter files by the extension
  • size in html4 mode is available only after the file has been uploaded
  • serverName is available only after the file has been uploaded
  • (1) works in html4/html5/flash modes, Chrome/Opera/Safari/FF/IE11/IE10
See also
Change log
  • added in version 2.0
  • lastModifiedDate attribute added in 2.3
Back to top