# file-manager-directory-upload

> File manager with a toolbar dropdown to upload either individual files or a whole folder.

**Framework:** angular  **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/angular/file-manager-directory-upload.json
```

**Install Package(s)**

```bash
npm install @syncfusion/ej2-angular-filemanager @syncfusion/ej2-angular-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.component.html

```html
<div class="sample-container">
    <ejs-filemanager id='file' #fileObj [ajaxSettings]='ajaxSettings' [contextMenuSettings]="contextMenuSettings" (success)="onSuccess()" >
      <e-toolbaritems>
        <e-toolbaritem name="NewFolder"></e-toolbaritem>
        <e-toolbaritem name="Upload">
          <ng-template #template>
            <button ejs-dropdownbutton id="dropButton" [items]='items' cssClass="e-tbar-btn e-tbtn-txt" iconCss="e-icons e-fe-upload" (select)="onSelect($event)"><span class="e-tbar-btn-text">{{ uploadLabel }}</span></button>
          </ng-template>
        </e-toolbaritem>
        <e-toolbaritem name="SortBy"></e-toolbaritem>
        <e-toolbaritem name="Refresh"></e-toolbaritem>
        <e-toolbaritem name="Cut"></e-toolbaritem>
        <e-toolbaritem name="Copy"></e-toolbaritem>
        <e-toolbaritem name="Paste"></e-toolbaritem>
        <e-toolbaritem name="Delete"></e-toolbaritem>
        <e-toolbaritem name="Download"></e-toolbaritem>
        <e-toolbaritem name="Rename"></e-toolbaritem>
        <e-toolbaritem name="Selection"></e-toolbaritem>
        <e-toolbaritem name="View"></e-toolbaritem>
        <e-toolbaritem name="Details"></e-toolbaritem>
      </e-toolbaritems>        
    </ejs-filemanager>
</div>

```

### src/components/file-manager-directory-upload/file-manager.component.ts

```typescript
import { Component, ViewEncapsulation, ViewChild } from '@angular/core';
import { FileManagerComponent, NavigationPaneService, ToolbarService, DetailsViewService, FileManagerModule } from '@syncfusion/ej2-angular-filemanager';
import { ItemModel, DropDownButtonModule } from '@syncfusion/ej2-angular-splitbuttons';
/**
 * File Manager directory upload feature sample
 */

@Component({
    selector: 'control-content',
    templateUrl: 'file-manager.component.html',
    styleUrls: ['../file-manager-common.style.css'],
    encapsulation: ViewEncapsulation.None,
    providers: [NavigationPaneService, ToolbarService, DetailsViewService],
    standalone: true,
    imports: [FileManagerModule, DropDownButtonModule]
})

export class DirectoryUploadController {
    @ViewChild('fileObj')
    public fileObj!: FileManagerComponent;
    public ajaxSettings!: object;
    public contextMenuSettings!: object;
    public uploadLabel: string = 'Upload';
    public hostUrl: string = 'https://physical-service.syncfusion.com/';
    public ngOnInit(): void {
        this.ajaxSettings = {
            url: this.hostUrl + 'api/FileManager/FileOperations',
            getImageUrl: this.hostUrl + 'api/FileManager/GetImage',
            uploadUrl: this.hostUrl + 'api/FileManager/Upload',
            downloadUrl: this.hostUrl + 'api/FileManager/Download'
        };
        this.contextMenuSettings = {
            file: [ 'Cut', 'Copy', '|', 'Delete', 'Download', 'Rename', '|', 'Details'],
            visible: true
        };
    }
    //DropDownButton items definition
    public items: ItemModel[] = [];
    public onSuccess() {
        this.uploadLabel = this.fileObj.localeObj.getConstant('Upload');
        this.items = [
            { text: this.fileObj.localeObj.getConstant('Folder') },
            { text: this.fileObj.localeObj.getConstant('File') },
        ];
        if (document.getElementById("dropButton")!.classList.contains("e-dropdown-btn")) {
            let customBtn: HTMLElement = document.getElementById('dropButton')!;
            customBtn.onclick = (e) => {
                e.stopPropagation();
            };
        }
    }

    public onSelect(args: any): void {
        if (args.item.text === this.fileObj.localeObj.getConstant('Folder')) {
            this.fileObj.uploadSettings.directoryUpload = true;
        } else {
            this.fileObj.uploadSettings.directoryUpload = false;
        }
        setTimeout(function () {
            let uploadBtn: HTMLElement = document.querySelector('.e-file-select-wrap button') as HTMLElement;
            uploadBtn.click();
        }, 100);
    }
}

```
