# ASP.NET MVC Upload Overview

The Telerik UI Upload HtmlHelper for ASP.NET MVC is a server-side wrapper for the Kendo UI Upload widget.

The Upload uses progressive enhancement to deliver the best possible uploading experience to users, without requiring extra developer effort.

* [Demo page for the Upload HtmlHelper](https://demos.telerik.com/aspnet-mvc/upload/index)

## Initializing the Upload

The following example demonstrates how to define the Upload widget.

```Razor
@(Html.Kendo().Upload()
    .Name("files")
    .Async(a => a
        .Save("Save", "Upload")
        .Remove("Remove", "Upload")
        .AutoUpload(true)
    )
)
```

```C# Controller
public ActionResult Save(IEnumerable<HttpPostedFileBase> files)
{
    // The Name of the Upload component is "files"
    if (files != null)
    {
        foreach (var file in files)
        {
            // Some browsers send file names with full path.
            // We are only interested in the file name.
            var fileName = Path.GetFileName(file.FileName);
            var physicalPath = Path.Combine(Server.MapPath("~/App_Data"), fileName);

            // The files are not actually saved in this demo
            // file.SaveAs(physicalPath);
        }
    }

    // Return an empty string to signify success
    return Content("");
}

public ActionResult Remove(string[] fileNames)
{
    // The parameter of the Remove action must be called "fileNames"

    if (fileNames != null)
    {
        foreach (var fullName in fileNames)
        {
            var fileName = Path.GetFileName(fullName);
            var physicalPath = Path.Combine(Server.MapPath("~/App_Data"), fileName);

            // TODO: Verify user permissions

            if (System.IO.File.Exists(physicalPath))
            {
                // The files are not actually removed in this demo
                // System.IO.File.Delete(physicalPath);
            }
        }
    }

    // Return an empty string to signify success
    return Content("");
}
```

## Basic Configuration

The following example demonstrates the basic configuration of the Upload component and how to get the Upload widget instance.

An Upload widget configured in such way offers support for multiple file selection, asynchronous removal of uploaded files, progress tracking, in-progress cancellation of upload, file drag-and-drop. Progress tracking, file drag-and-drop, and in-progress cancellation of upload are automatically enabled if supported by the browser.

> The Upload works in `<input type="file" />` elements, so it is only able to upload files selected by the user, which exist in the file system. For uploading files generated with JavaScript on the fly, use another approach, e.g. an Ajax request.

```Razor HtmlHelper
@(Html.Kendo().Upload()
    .Name("files")
    .Multiple(true)
    .Async(a => a
        .Save("ChunkSave", "Upload")
        .Remove("Remove", "Upload")
        .AutoUpload(true)
        .ChunkSize(1100)
    )
)

<script type="text/javascript">
    $(function() {
        // The Name() of the Upload is used to get its client-side instance.
        var files = $("#files").data("kendoUpload");
    });
</script>
```

## Functionality and Features

| Feature                                                                                                                      | Description                                                                                                                                                                                                                                         |
| ---------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Modes of operation](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/upload/modes-of-operation)        | You can specify whether the Upload behaves like a regular file input or like a standalone component with asynchronous operations.                                                                                                                   |
| [Chunk upload of files](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/upload/chunk-upload)           | You can send large chunks of files that will be processed asynchronously.                                                                                                                                                                           |
| [Dragging and dropping of files](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/upload/drag-and-drop) | The Upload enables you to drag and drop items within the component's drop zone.                                                                                                                                                                     |
| [Identification of files](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/upload/identify-files)       | You can identify the file object during its upload process.                                                                                                                                                                                         |
| [Sending and receiving metadata](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/upload/send-meta)     | You can send additional information to the specified endpoint which is used for storing the uploaded file.                                                                                                                                          |
| [Validation of files](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/upload/validation)               | The Upload enables you to integrate file validation for each of the selected files.                                                                                                                                                                 |
| [Uploading directories](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/upload/directory-upload)       | The component supports uploading of entire directories, preserving their structure.                                                                                                                                                                 |
| [Templates](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/upload/templates)                          | Customize the appearance of the files in the file list.                                                                                                                                                                                             |
| [Form Integration](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/upload/form-integration)            | You can use the Upload as an editor in a form.                                                                                                                                                                                                      |
| [Events](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/upload/events)                                | The Upload allows you to handle its file processing events and implement custom functionality.                                                                                                                                                      |
| [Accessibility](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/upload/accessibility/overview)         | The Upload is accessible for screen readers, supports WAI-ARIA attributes, and delivers [keyboard shortcuts](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/upload/accessibility/keyboard-navigation) for faster navigation. |

## Next Steps

* [Getting Started with the Upload](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/upload/getting-started)

* [Basic Usage of the Upload HtmlHelper for ASP.NET MVC (Demo)](https://demos.telerik.com/aspnet-mvc/upload)

* [Using the API of the Upload HtmlHelper for ASP.NET MVC (Demo)](https://demos.telerik.com/aspnet-mvc/upload/api)

## See Also

* [Using the API of the Upload HtmlHelper for ASP.NET MVC (Demo)](https://demos.telerik.com/aspnet-mvc/upload/api)
* [Server-Side API for ASP.NET MVC](https://www.telerik.com/aspnet-mvc/documentation/api/upload)
* [Client-Side API](https://docs.telerik.com/kendo-ui/api/ui/upload)
* [Knowledge Base Section](https://www.telerik.com/aspnet-mvc/documentation/knowledge-base)
