Is there a way to define the file upload controls using a Razor helper in ASP.NET MVC3?
USING RAZOR
@*requieres installing Asp helpers / you can do it her from NuGet or logging som admin in packages*@
@using Microsoft.Web.Helpers;
@{
var fileName = "";
if (IsPost) {
var fileSavePath = "";
var uploadedFile = Request.Files[0];
fileName = Path.GetFileName(uploadedFile.FileName);
fileSavePath = Server.MapPath("~/UploadedFiles/" +
fileName);
uploadedFile.SaveAs(fileSavePath);
}
}
@FileUpload.GetHtml(
initialNumberOfFiles:1,
allowMoreFilesToBeAdded:false,
includeFormTag:false,
name: "Upload1",
uploadText:"Upload")
@if (IsPost) {
File uploaded!
}