Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
here is the solution suggested to me
stackoverflow.com/questions/4784225/mvc-3-file-upload-and-model-binding
I have not worked with Azure, but I think it will be something like this:
[HttpPost]
public ActionResult UploadForm(string ProductName, string Code, string Url)
{
var files = HttpContext.Request.Files;
StreamReader stream = new StreamReader(files[0].InputStream);
var fileToAdd = default(byte[]);
using (var memstream = new MemoryStream())
{
stream.BaseStream.CopyTo(memstream);
fileToAdd = memstream.ToArray();
}
// функция добавления записи в бд:
AddData(ProductName, Code, Url, fileToAdd);
return null;
}
The following code is working for me
Model
public class Book
{
public string Title {get;set;}
public string Author {get;set;}
}
public class BookController : Controller
{
[HttpPost]
public ActionResult Create(Book model, IEnumerable<HttpPostedFileBase> fileUpload)
{
throw new NotImplementedException();
}
}
@using (Html.BeginForm("Create", "Book", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
@Html.EditorFor(m => m)
<input type="file" name="fileUpload[0]" /><br />
<input type="file" name="fileUpload[1]" /><br />
<input type="file" name="fileUpload[2]" /><br />
<input type="submit" name="Submit" id="SubmitMultiply" value="Upload" />
}
<input type="file" name="fileUpload[0]" />
IEnumerable<HttpPostedFileBase> fileUpload
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question