# file-manager-file-upload

> File manager demonstrating file upload operations with an upload-enabled toolbar.

**Framework:** aspnet-mvc  **Component:** FileManager  **Variant:** file-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/aspnet-mvc/file-manager-file-upload.json
```

**Install Package(s)**

```bash
Install-Package Syncfusion.AspNetMvc.FileManager
Install-Package Syncfusion.AspNetMvc.Buttons
Install-Package Syncfusion.AspNetMvc.Inputs
Install-Package Syncfusion.AspNetMvc.Popups
```

**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-file-upload/FileManager.cshtml

```cshtml
@using Syncfusion.EJ2.FileManager
@using Syncfusion.EJ2.Inputs
@using Syncfusion.EJ2.Buttons
@using Syncfusion.EJ2.Popups
@using EJ2MVCSampleBrowser.Models
@{
    string[] items = new string[] { "NewFolder", "Upload", "Cut", "Copy", "Delete", "Rename", "SortBy", "Refresh", "Selection", "View", "Details" };
    string[] file = new string[] { "Cut", "Copy", "|", "Delete", "Download", "Rename", "|", "Details" };
}
@section ControlsSection{
    <div class="control-section">
        <div class="sample-container">
            <!-- File Manager real time use case sample -->
            <div id='container' class="fileupload">
                @Html.EJS().Uploader("UploadFile").Render()
                @Html.EJS().Button("openBtn").Content("File Browser").Render()
            </div>
            <div id='target' class="control-section">
                @*Dialog*@
                @Html.EJS().Dialog("dialog").AnimationSettings(new DialogAnimationSettings() { Effect = DialogEffect.None }).Created("onDialogLoad").Close("dialogClose").Open("dialogOpen").Header("Select a file").Visible(false).ShowCloseIcon(true).Width("850px").Target("#target").ContentTemplate(@<div class='dialogContent'>
                    @Html.EJS().FileManager("filemanager").AjaxSettings(new Syncfusion.EJ2.FileManager.FileManagerAjaxSettings  {
                        Url = Url.Content("~/FileManager/FileOperations"),
                        DownloadUrl = Url.Content("~/FileManager/Download"),
                        UploadUrl = Url.Content("~/FileManager/Upload"),
                        GetImageUrl = Url.Content("~/FileManager/GetImage")
               }).ToolbarSettings(new Syncfusion.EJ2.FileManager.FileManagerToolbarSettings() { Items = items }).ContextMenuSettings(new Syncfusion.EJ2.FileManager.FileManagerContextMenuSettings() {
                   File = file
               }).FileOpen("onFileOpen").Render()</div>).Render()
            </div>
        </div>
    </div>
    
}

@*@section PreScripts {*@
    <script>
        function onDialogLoad() {
            document.getElementById("openBtn").addEventListener('click', function () {
                var dialogObj = document.getElementById('dialog').ej2_instances[0];
                dialogObj.show();
                var filemanagerObj = document.getElementById('filemanager').ej2_instances[0];
                filemanagerObj.path = "/";
                filemanagerObj.selectedItems = [];
                filemanagerObj.refresh();
            });
        }
        // Uploader will be hidden, if Dialog is opened
        function dialogOpen() {
            document.getElementById('container').style.display = 'none';
        }
        // Uploader will be shown, if Dialog is closed
        function dialogClose() {           
            document.getElementById('container').style.display = 'block';
        }
        // File Manager's fileOpen event function
        function onFileOpen(args) {
            var file = args.fileDetails;
            if (file.isFile) {
                args.cancel = true;
                if (file.size <= 0 ) { file.size = 10000; }
                var uploadObject = document.getElementById('UploadFile').ej2_instances[0];
                var dialogObj = document.getElementById('dialog').ej2_instances[0];
                uploadObject.files = [{name: file.name, size: file.size, type: file.type }];
                dialogObj.hide();
            }
        }
    </script>
@*}*@

<style>
    .fileupload {
        max-width: 500px;
        margin: auto;
    }

    #openBtn {
        position: absolute;
        top: 28px;
        left: 43%;
    }

    .tailwind #openBtn,
    .tailwind-dark #openBtn {
        top: 28px;
    }

    .bootstrap #openBtn,
    .bootstrap-dark #openBtn {
        top: 30px;
    }

    .bootstrap5 #openBtn,
    .bootstrap5-dark #openBtn {
        top: 26px;
    }

    #target {
        height: 550px;
    }
    #dialog {
        top: 20px !important;
        max-height: 500px !important;
    }
    .fileupload .e-file-drop, .fileupload .e-css.e-btn {
        display: none;
    }

    .fluent2 .fileupload .e-file-select-wrap {
        padding: 20px 0 20px 20px;
    }
</style>
```

### src/components/file-manager-file-upload/FileManagerController.cs

```cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Syncfusion.EJ2.Popups;

namespace EJ2MVCSampleBrowser.Controllers
{
    public partial class FileManagerController : Controller
    {
        // GET: FileUpload
        public ActionResult FileUpload()
        {
            return View("~/Views/Home/file-manager/file-upload/FileManager.cshtml");
        }
    }
}
```
