This is my Code. I want to uplade 3 file into my database
first in View I write this : <% using (Html.BeginForm(Actionname, Controller, FormMethod.Post, new {enctype="multipart/form-data"})){%> ..... ....
and this is 3 file uplaoding:
<input type="file" name="files" id="FileUpload1" />
<input type="file" name="files" id="FileUpload2" />
<input type="file" name="files" id="FileUpload3" />
In controller I use this code:
IEnumerable<HttpPostedFileBase> files = Request.Files["files"] as IEnumerable<HttpPostedFileBase>;
foreach (var file in files)
{
byte[] binaryData = null;
HttpPostedFileBase uploadedFile = file;
if (uploadedFile != null && uploadedFile.ContentLength > 0){
binaryData = new byte[uploadedFile.ContentLength];
uploadedFile.InputStream.Read(binaryData, 0,uploadedFile.ContentLength);
}
}
but the files always return NULL :(
please help me, thank you.