Upload - Telerik Extensions for ASP.NET MVC
Step 1
In view you have to put following code:
<td
class="adminData">
@(Html.Telerik().Upload().Name("vchImage").Multiple(false).Async(async
=> async.AutoUpload(false).Save("Save",
"TestProductCategory") ) ) @Html.EditorFor(model
=> model.vchImage)@Html.ValidationMessageFor(model
=> model.vchImage)
</td>
Step 2
Then in Controller:
public
ActionResult Save(IEnumerable<HttpPostedFileBase> vchImage)
{
//
The Name of the Upload component is "attachments"
foreach (var file in
vchImage)
{
// Some
browsers send file names with full path. This needs to be stripped.
var fileName =
Path.GetFileName(file.FileName);
TempData["abc"]
= 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("");
}
Now you are able uplode file in MVC4 With Telrik Extension