Hi,
I already tried the sample in
but unfortunately i got error like this
https://pasteboard.co/J3aSp9q.png
Any idea why this happen?
public ActionResult ImageProven(ItemModel model)
{
string id = model.Form_Id.ToString();
if (model != null)
{
var addImage = db.tbl_detailItem.Where(z => z.item_id == model.item_id).FirstOrDefault();
if (model.file1 != null)
{
var allowedExtensions = new[] { ".Jpg", ".png", ".jpg", "jpeg", ".pptx" };
var fileName = Path.GetFileName(model.file1.FileName); //getting only file name
var ext = Path.GetExtension(model.file1.FileName); //getting the extension(ex-.jpg)
if (allowedExtensions.Contains(ext)) //check what type of extension
{
string name = Path.GetFileNameWithoutExtension(fileName); //getting file name without extension
string myfile = name + ext;
// store the file inside ~/project folder(Img)
var path = Path.Combine(Server.MapPath("~/ImageStore/form/"), myfile);
model.file1.SaveAs(path);
addImage.auditeeAttach = "~/ImageStore/form/" + myfile;
if (String.IsNullOrEmpty(addImage.auditeeAttach))
{
addImage.auditeeAttach = "~/ImageStore/form/";
}
}
else
{
ViewBag.message = "Please choose only Image file or Email File";
return View();
}
}
db.SaveChanges();
}
return RedirectToAction("AuditeeListItemDetail", "Auditee", new { id });
}