---
title: "How to file upload in mvc?"  
description: "How to file upload in mvc?"  
author: "marcel ethan"  
published: 2014-10-06  
updated: 2014-10-06  
canonical: https://www.mindstick.com/forum/2315/how-to-file-upload-in-mvc  
category: "asp.net mvc"  
tags: ["asp.net", "asp.net mvc"]  
reading_time: 1 minute  

---

# How to file upload in mvc?

How can I [upload](https://www.mindstick.com/forum/12860/how-to-upload-file-asynchronously-using-generic-handler) the [file](https://www.mindstick.com/articles/59/encrypting-and-decrypting-files-using-c-sharp) using [html input](https://www.mindstick.com/forum/157343/how-to-prevent-a-user-from-adding-same-character-over-and-over-in-html-input-box-using-javascript) file [control](https://www.mindstick.com/blog/197/asp-dot-net-repeater-control)

## Replies

### Reply by Anonymous User

You don't use a file [input](https://www.mindstick.com/forum/159209/how-can-i-read-convert-an-input-stream-into-a-string-in-java) control. Server side controls are not used in ASP.NET MVC.

So you would start by creating an [HTML](https://www.mindstick.com/articles/1530/design-a-simple-stylish-calculator-using-html-css-and-javascript) form which would contain a file input.

\

```
 @using (Html.BeginForm("Index", "Home", FormMethod.Post, new { enctype = "multipart/form-data" })){    <input type="file" name="file" />    <input type="submit" value="OK" />}
```

and then you would have a controller to handle the upload.\

```
public class HomeController : Controller        {            public ActionResult Index()            {                return View();            }             [HttpPost]            public ActionResult Index(HttpPostedFileBase file)            {                if (file != null && file.ContentLength > 0)                {                    var fileName = Path.GetFileName(file.FileName);                    var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName);                    file.SaveAs(path);                }                return RedirectToAction("Index");            }        }
```


---

Original Source: https://www.mindstick.com/forum/2315/how-to-file-upload-in-mvc

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
