The following code execute successfully (multliple images),but at the time of edit I am not upload any images click save button same data will update in database,This is not working
editing time not upload any image same data upload,This time not execute this block of statements
if (MultipleFiles != null)
{}
Error i am getting:Object reference not set to an instance of an object.
[HttpPost]
public ActionResult Edit(int id, Product collection, HttpPostedFileBase[] MultipleFiles)
{
Product p = db.Products.Single(e => e.TagID == id);
List<string> blobs = new List<string>();
if (MultipleFiles != null)
{
foreach (var fileBase in MultipleFiles)
{
if (fileBase != null && fileBase.ContentLength > 0)
{
// Retrieve a reference to a container
CloudBlobContainer blobContainer = _myBlobStorageService.GetCloudBlobContainer();
CloudBlob blob = blobContainer.GetBlobReference(fileBase.FileName);
// Create or overwrite the "myblob" blob with contents from a local file
blob.UploadFromStream(fileBase.InputStream);
}
CloudBlobContainer blobContainer1 = _myBlobStorageService.GetCloudBlobContainer();
CloudBlob blob1 = blobContainer1.GetBlobReference(fileBase.FileName);
blobs.Add(blob1.Uri.ToString());
}
p.Image = blobs.ElementAt(0).ToString();
p.Image1 = blobs.ElementAt(1).ToString();
}
// TODO: Add update logic here
p.Name = collection.Name;
p.Price = collection.Price;
p.Description = collection.Description;
//p.Image = collection.Image;
// p.Image1 = collection.Image1;
db.SubmitChanges();
return RedirectToAction("Index");
}