# file-manager-directory-upload

> File manager with a toolbar dropdown to upload either individual files or a whole folder.

**Framework:** vue  **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/vue/file-manager-directory-upload.json
```

**Install Package(s)**

```bash
npm install @syncfusion/ej2-vue-filemanager @syncfusion/ej2-vue-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/FileManager.vue

```vue
<template>
  <div class="control-section folder-upload">
    <div class="sample-container">
      <ejs-filemanager
        id="filemanager"
        ref="filemanagerInstance"
        :ajaxSettings="ajaxSettings"
        :contextMenuSettings="contextMenuSettings"
        @success="onSuccess"
      >
        <e-toolbaritems>
          <e-toolbaritem name="NewFolder"></e-toolbaritem>
          <e-toolbaritem :template="'uploadTemplate'" name="Upload">
            <template v-slot:uploadTemplate>
              <div>
                <ejs-dropdownbutton
                  id="dropButton"
                  cssClass="e-tbar-btn e-tbtn-txt"
                  iconCss="e-icons e-fe-upload"
                  :items="getItems()"
                  :content="uploadContent"
                  :select="onSelect"
                  :onClick="uploadClick"
                />
              </div>
            </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>
  </div>
</template>

<script lang="ts">
import { FileManagerComponent, NavigationPane, Toolbar, DetailsView, ToolbarItemDirective, ToolbarItemsDirective } from '@syncfusion/ej2-vue-filemanager';
import { DropDownButtonComponent } from '@syncfusion/ej2-vue-splitbuttons';

const hostUrl = 'https://physical-service.syncfusion.com/';

export default {
  components: {
    'ejs-filemanager': FileManagerComponent,
    'ejs-dropdownbutton': DropDownButtonComponent,
    'e-toolbaritem': ToolbarItemDirective,
    'e-toolbaritems': ToolbarItemsDirective
  },
  data() {
    return {
      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
      },
      uploadContent: '<span class="e-tbar-btn-text">Upload</span>'
    };
  },
  provide() {
    return {
      filemanager: [NavigationPane, DetailsView, Toolbar]
    };
  },
  methods: {
    getItems() {
      const fileObj = (this.$refs.filemanagerInstance as any)?.ej2Instances;
      return [
        { text: fileObj?.localeObj.getConstant('Folder') },
        { text: fileObj?.localeObj.getConstant('File') }
      ];
    },
    onSuccess() {
      const fm = (this.$refs.filemanagerInstance as any).ej2Instances;
      const label = fm.localeObj.getConstant('Upload');
      this.uploadContent = `<span class="e-tbar-btn-text">${label}</span>`;
    },
    onSelect(args: any) {
      const fileObj = this.$refs.filemanagerInstance as any;
      const fileObject = fileObj?.ej2Instances;
      if (args.item.text === fileObject?.localeObj.getConstant('Folder')) {
        fileObj.ej2Instances.uploadSettings.directoryUpload = true;
      } else {
        fileObj.ej2Instances.uploadSettings.directoryUpload = false;
      }
      setTimeout(function () {
        const uploadBtn = document.querySelector('.e-file-select-wrap button') as HTMLElement;
        uploadBtn.click();
      }, 100);
    },
    uploadClick(args: MouseEvent) {
      args.stopPropagation();
    }
  }
};
</script>

<style scoped>
.folder-upload .sample-container {
  margin: 10px 10px 10px 10px;
}
</style>

```
