DevExtreme React - Getting Started with File Manager
The FileManager widget allows users to manage files and folders.
Create a File Manager
The following code creates the FileManager widget and adds it to your page.
jQuery
$(function () { $("#file-manager").dxFileManager({ fileProvider: fileSystem, currentPath: "Documents", height: 450, permissions: { create: true, copy: true, move: true, remove: true, rename: true } }); });
<div id="file-manager"></div>
var fileSystem = [ { name: "Documents", isDirectory: true, items: [ { name: "Projects", isDirectory: true, items: [ { name: "About.rtf", isDirectory: false, size: 1024 }, { name: "Passwords.rtf", isDirectory: false, size: 2048 } ] }, { name: "About.xml", isDirectory: false, size: 1024 }, { name: "Managers.rtf", isDirectory: false, size: 2048 }, { name: "ToDo.txt", isDirectory: false, size: 3072 } ], }, // ... ];
Bind the File Manager Widget to a File System
Create a file provider that allows you to access and modify file systems.
To bind the FileManager widget to a hierarchical data structure, create an Array file provider and assign the array of hierarchical JSON objects to the provider's data option. The Array file provider automatically binds data objects to the widget if the data objects have the default 'name', 'size', 'dateModified', etc., fields in their structure. For example:
var fileSystem = [ { name: "MyFile.jpg", size: 1024, dateModified: "2019/05/08", thumbnail: "/thumbnails/images/jpeg.ico", isDirectory: true, items: [ // ... // Nested data objects with the same structure // ... ] // ... }];
In the example below, the FileManager widget displays hierarchical data stored in an in-memory array that contains fields with conventional names:
jQuery
$(function() { $("#file-manager").dxFileManager({ fileProvider: fileSystem, // ... }); });
var fileSystem = [ { name: "Documents", isDirectory: true, items: [ { name: "Projects", isDirectory: true, items: [ { name: "About.rtf", isDirectory: false, size: 1024 }, { name: "Passwords.rtf", isDirectory: false, size: 2048 } ] }, { name: "About.xml", isDirectory: false, size: 1024 }, { name: "Managers.rtf", isDirectory: false, size: 2048 }, { name: "ToDo.txt", isDirectory: false, size: 3072 } ], }, //... ];
See Also
If you have technical questions, please create a support ticket in the DevExpress Support Center.