This is my table
Id name Img Imag1 Img2
MYCODE:
[HttpPost, ValidateInput(false)]
public ActionResult Create(FormCollection collection, ProductsConyers2 p, HttpPostedFileBase[] MultipleFiles,TagTable tb)
{
try
{
// TODO: Add insert logic here
var Tagid = collection["TagNo"];
var qry = (from c in db.ProductsConyers2s where c.Id ==Id select c).Count();
if (qry != 1)
{
foreach (var fileBase in MultipleFiles)
{
if (fileBase.ContentLength > 0)
{
Microsoft.WindowsAzure.StorageClient.CloudBlobContainer blobContainer = _myBlobStorageService.GetCloudBlobContainer();
CloudBlob blob = blobContainer.GetBlobReference(fileBase.FileName);
blob.UploadFromStream(fileBase.InputStream);
}
}
List<string> blobs = new List<string>();
foreach (var fileBase in MultipleFiles)
{
Microsoft.WindowsAzure.StorageClient.CloudBlobContainer blobContainer1 = _myBlobStorageService.GetCloudBlobContainer();
CloudBlob blob1 = blobContainer1.GetBlobReference(fileBase.FileName);
blobs.Add(blob1.Uri.ToString());
}
p.Img = blobs.ElementAt(0).ToString();
p.Img1 = blobs.ElementAt(1).ToString();
p.Img2 = blobs.ElementAt(2).ToString();
db.ProductsConyers2s.InsertOnSubmit(p);
db.SubmitChanges();
return RedirectToAction("Products");
}
}
MYVIEW:
@using (Html.BeginForm("Create", "Controller", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<legend>ProductsHondaofConyer</legend>
<div class="editor-label">
@Html.LabelFor(model => model.ID)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.ID)
@Html.ValidationMessageFor(model => model.ID)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Name)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Img)
</div>
<div class="editor-field">
@*@Html.EditorFor(model => model.Img)*@
<input type="file" name="MultipleFiles" />
@Html.ValidationMessageFor(model => model.Img)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Img1)
</div>
<div class="editor-field">
@*@Html.EditorFor(model => model.Img1)*@
<input type="file" name="MultipleFiles" />
@Html.ValidationMessageFor(model => model.Img1)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Img2)
</div>
<div class="editor-field">
@*@Html.EditorFor(model => model.Img2)*@
<input type="file" name="MultipleFiles" />
@Html.ValidationMessageFor(model => model.Img2)
</div>
}
I am doing this working fine,
I can upload three images successfully uploaded
But I can upload 2 images 1 image not upload?
Anyone can change my code logic