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:
<!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:
uploadUrl | string | path to server script for html5/html4 modes |
swfPath | string | path to uploader.swf file1) |
swfUrl | string | path to the server script for flash mode (relative to dhxvault.swf) |
slXap | string | path to dhxvault.xap file (full path is required, i.e. including https://host.. ) |
slUrl | string | path to server script for sl mode (full path is required, i.e. https://.../server.php) |
there are also several optional keys:
skin | string | sets the skin, dhx_skyblue (default), dhx_web or dhx_terrace |
autoStart | boolean | enables automatic uploading right after a file has been added |
autoRemove | boolean | enables automatic removing of files right after uploading has been completed |
buttonUpload | boolean | shows/hides the "Upload"/"Stop" button |
buttonClear | boolean | shows/hides the "Clear all" button |
filesLimit | number | sets the maximum number of files allowed to be added |
paramName | string | optional, changes file's param name in request, 'file' is default |
multiple | boolean | optional, set to false to disable multiple file selection |
maxFileSize | number | optional, 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.