Check documentation for the latest version of dhtmlxSuite Initializing Vault DHTMLX Docs

Initializing Vault

This documentation is for Vault v2.5. Please go to docs.dhtmlx.com/vault/ to see documentation for the current version of dhtmlxVault.

Firstly, you need to include dhtmlxVault source files on the page:

  • dhtmlxvault.js
  • dhtmlxvault.css
<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="dhtmlxvault.css"/>
        <script src="dhtmlxvault.js"></script>
    </head>
    <body>
    ...
    </body>
</html>

Then define a container to place the file uploader into:

<div id="vaultObj" style="width:400px; height:250px;"></div>

Finally, create a dhtmlxVaultObject instance:

// init on object on page
var myVault = new dhtmlXVaultObject({
    container:  "vaultObj",             // html container for vault
    uploadUrl:  "server.php",           // html4/html5 upload url
    swfPath:    "dhxvault.swf",         // path to flash uploader
    swfUrl:     "server.php",           // flash upload url
    slXap:      "dhxvault.xap",         // path to silverlight uploader
    slUrl:      "https://.../server.php"    // silverlight upload url, FULL path required
});

You can also attach vault to any container component (like window, layout)

var myLayout = new dhtmlXLayoutObject("parentId", "2E");
var myVault = myLayout.cells(id).attachVault(conf);

param conf - object with the following keys:

uploadUrlstringpath to server script for html5/html4 modes
swfPathstringpath to uploader.swf file1)
swfUrlstringpath to the server script for flash mode (relative to dhxvault.swf)
slXapstringpath to dhxvault.xap file (full path is required, i.e. including https://host.. )
slUrlstringpath to server script for sl mode (full path is required, i.e. https://.../server.php)

there are also several optional keys:

skinstringsets the skin, dhx_skyblue (default), dhx_web or dhx_terrace
autoStartbooleanenables automatic uploading right after a file has been added
autoRemovebooleanenables automatic removing of files right after uploading has been completed
buttonUploadbooleanshows/hides the "Upload"/"Stop" button
buttonClearbooleanshows/hides the "Clear all" button
filesLimitnumbersets the maximum number of files allowed to be added
paramNamestringoptional, changes file's param name in request, 'file' is default
multiplebooleanoptional, set to false to disable multiple file selection
maxFileSizenumberoptional, sets max file size allowed on the server 2)

1) Path to swfUrl should be relative to swfPath. But in IE browsers depending on Flash Player version installed, swfUrl is set relatively to the 'index.html' file.
So, we recommend to keep swf-file in the same folder that the 'index.html' file is located, to make path relative both to 'index.html' and swfUrl. By 'index.html' file we mean an HTML file where vault init code called.

2) Vault also makes a try to load maxFileSize from server with request to uploadUrl and mode=conf params.
Server may return {maxFileSize: 1234567} response or may not.
If maxFileSize was not set via config on init stage and server returned valid numeric maxFileSize greater than zero in conf-response, vault will use maxFileSize returned by conf-response.

Back to top