# file-manager-directory-upload

> File manager with a toolbar dropdown to upload either individual files or a whole folder.

**Framework:** javascript  **Component:** FileManager  **Variant:** directory-upload

## Get this item

**If you are an agent, fetch the JSON.** Source is inlined, so one request is enough and no tooling is required:

```
GET https://ai.syncfusion.com/r/javascript/file-manager-directory-upload.json
```

**Install Package(s)**

```bash
npm install @syncfusion/ej2-filemanager @syncfusion/ej2-splitbuttons
```

**Notes**

- Syncfusion release: 2026 Volume 3 (v35.1.37)
- The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md

## Source files

### src/components/file-manager-directory-upload/file-manager.html

```html
<div class="control-section">
    <div class="sample-container">
        <!-- Initialize FileManager -->
        <div id="container"></div>
    </div>
</div>

```

### src/components/file-manager-directory-upload/file-manager.ts

```typescript
import { FileManager, Toolbar, NavigationPane, DetailsView, ContextMenu } from '@syncfusion/ej2-filemanager';
import { DropDownButton, type ItemModel } from '@syncfusion/ej2-splitbuttons';
FileManager.Inject(Toolbar, NavigationPane, DetailsView, ContextMenu);

/**
 * File Manager folder upload sample
 */
export function initFileManagerDirectoryUpload(): void {
    var buttonTemplate = '<button id="dropButton" class="e-tbar-btn e-tbtn-txt"> <span class="e-tbar-btn-text">Upload</span> </button>';
    let hostUrl: string = 'https://physical-service.syncfusion.com/';
    let fileObject: FileManager = new FileManager({
        ajaxSettings: {
            url: hostUrl + 'api/FileManager/FileOperations',
            getImageUrl: hostUrl + 'api/FileManager/GetImage',
            uploadUrl: hostUrl + 'api/FileManager/Upload',
            downloadUrl: hostUrl + 'api/FileManager/Download'
        },
        contextMenuSettings: {
            file: [ "Cut", "Copy", "|", "Delete", "Download", "Rename", "|", "Details"],
            visible: true
        },
        toolbarItems: [{ name: 'NewFolder' },
            { template: buttonTemplate, name: 'Upload' },
            { name: 'SortBy' },
            { name: 'Refresh' },
            { name: 'Cut' },
            { name: 'Copy' },
            { name: 'Paste' },
            { name: 'Delete' },
            { name: 'Download' },
            { name: 'Rename' },
            { name: 'Selection' },
            { name: 'View' },
            { name: 'Details' }],
            success: onSuccess
    });
    fileObject.appendTo('#container');
    function onSuccess() {
        if (!document.getElementById('dropButton').classList.contains('e-dropdown-btn')) {
            let items: ItemModel[] = [{ text: fileObject.localeObj.getConstant('Folder') }, { text: fileObject.localeObj.getConstant('File') }];
            new DropDownButton({
                    items: items,
                    iconCss: 'e-icons e-fe-upload',
                    select: (args) => {
                        if (args.item.text === fileObject.localeObj.getConstant('Folder')) {
                            fileObject.uploadSettings.directoryUpload = true;
                        } else {
                            fileObject.uploadSettings.directoryUpload = false;
                        }
                        setTimeout(function () {
                            let uploadBtn: HTMLElement = document.querySelector('.e-file-select-wrap button');
                            uploadBtn.click();
                        }, 100);
                    }
            },'#dropButton');
            document.getElementById('dropButton').onclick = function (args) {
            args.stopPropagation();
        };
    }
    }
}

```
