# Display Directory Name and File Size in Upload

## Environment

<table>
 <tr>
  <td>Product</td>
  <td>Telerik UI for ASP.NET MVC Upload</td>
 </tr>
 <tr>
  <td>Progress Telerik UI for ASP.NET MVC version</td>
  <td>Created with the 2022.1.412 version</td>
 </tr>
</table>

## Description

How can I display the directory name and the total size of its content when working with the Telerik UI for ASP.NET MVC Upload?

## Solution

1. Hide the file list menu through the [`.ShowFileList()`](https://docs.telerik.com/aspnet-mvc/api/kendo.mvc.ui.fluent/uploadbuilder#showfilelistsystemboolean) configuration method.
2. Subscribe to the [`Select`](https://docs.telerik.com/aspnet-mvc/api/kendo.mvc.ui.fluent/uploadeventbuilder#selectsystemstring) event.
3. Get both the directory name and total file size in the `Select` event handler, and append them to the widget wrapper.

```Razor Index.cshtml
    @(Html.Kendo().Upload()
        .Name("files")
        .Async(a => a
            .Save("Directory_Upload_Chunk_Save", "Home")
            .Remove("Directory_Upload_Remove", "Home")
            .ChunkSize(11000)
        )
        .ShowFileList(false)
        .Directory(true)
        .DirectoryDrop(true)
        .Events(e=>e.Select("onSelect"))
        .Validation(validation =>
        {
            validation.MaxFileSize(20000000);
        })
    )
```

```JS script.js
    <script>
        function onSelect(e) {
            var directoryName = "";
            if (e.files.length) {
                directoryName = e.files[0].rawFile.webkitRelativePath.split("/")[0]; //get the directory name
            }

            var totalFileSize = 0;
            $.each(e.files, function (index, value) {
                totalFileSize += value.size; //sum up the total file size
            })
            var upload = $("#files").data("kendoUpload"); //get the reference of the upload component
            upload.wrapper.append("<div class='k-file'><p class='k-file-name'>Uploaded directory: " + directoryName
            + "</p><p class='k-file-size'>Total file size: "+totalFileSize+" KB</p></div>"); //append the custom content
        }
    </script>
```

For the complete implementation of the suggested approach, refer to the following [Telerik REPL](https://netcorerepl.telerik.com/mwEPueFY11892ccr56) example.

## More ASP.NET MVC Upload Resources

* [ASP.NET MVC Upload Documentation](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/upload/overview)

* [ASP.NET MVC Upload Demos](https://demos.telerik.com/aspnet-mvc/upload)

* [ASP.NET MVC Upload Product Page](https://www.telerik.com/aspnet-mvc/upload)

* [Telerik UI for ASP.NET MVC Video Onboarding Course (Free for trial users and license holders)](https://www.telerik.com/aspnet-mvc/documentation/getting-started/video-onboarding)

* [Telerik UI for ASP.NET MVC Forums](https://www.telerik.com/forums/aspnet-mvc)

## See Also

* [Telerik REPL: Display Directory Name and File Size in Upload](https://netcorerepl.telerik.com/mwEPueFY11892ccr56)
* [Client-Side API Reference of the Upload for ASP.NET MVC](https://docs.telerik.com/kendo-ui/api/ui/upload)
* [Server-Side API Reference of the Upload for ASP.NET MVC](https://docs.telerik.com/aspnet-mvc/api/upload)
* [Telerik UI for ASP.NET MVC Breaking Changes](https://www.telerik.com/aspnet-mvc/documentation/backwards-compatibility/2023-backwards-compatibility)
* [Telerik UI for ASP.NET MVC Knowledge Base](https://docs.telerik.com/aspnet-mvc/knowledge-base)
