This question is locked. New answers and comments are not allowed.
Greetings,
i m using upload control asp.net MVC.
i m using upload control asp.net MVC.
Upload.Multiple(true).Async(a => a.AutoUpload(true)
.Save("SaveFile", "Fichier", new { Area = "" })
.Remove("RemoveFile", "Fichier", new { Area = "" }));
in the list of uploaded file i have only fileName of each file i did upload.
my controller ;[HttpPost]
public ActionResult SaveFile()
{
var files = this.HttpContext.Request.Files;
var dbFile = new BinaryField();
if (files != null) {
for (int i = 0; i < files.Count; i++)
{
dbFile.Title = Path.GetFileNameWithoutExtension(files[i].FileName);
dbFile.Content = GetFileBytes(files[i]);
dbFile.Ext = Path.GetExtension(files[i].FileName);
dbFile.Ext = files[i].ContentType;
RepositoryInstance.SaveOrUpdate(dbFile);
}
} //return Content("");
return Json(new { Succces = true, Content = dbFile.Id, });
//return Json(new { id = dbFile.Id }, "text/plain");
}
[HttpPost]
public ActionResult RemoveFile(string fileNames)
{
int id = 22;
var dbFile = new BinaryField();
dbFile = RepositoryInstance.Get(id);
RepositoryInstance.Delete(dbFile);
RepositoryInstance.DbContext.CommitChanges();
//return Content("");
return Json(new { status = "OK" }, "text/plain");
}
how to deal whith RemoveFile to be able to remove file from DB using it's ID i got as json response in my SaveFile()
??
Thanks in advance