我想要发送参数类别,objid和城市到动作索引和索引页面使用删除区域选择放置区域中的多图像我想要插入类别,objid和图像名称与存储过程插入到数据库 现在一个图像延迟保存在数据库中 帮帮我?
此代码发送参数:
@Html.ActionLink("اپلود تصویر", "index", "Pictures", new { objid = item.Id, cityid = item.CityId, category = item.CategoryId }, null)
和索引代码:
public async Task<ActionResult> Index(int? objid, int? cityid, int? category)
{
if (objid != null )
{
TempData["id"] = objid;
TempData["city"] = cityid;
TempData["category"] = category;
}
bool isSavedSuccessfully = true;
string fName = "";
foreach (string fileName in Request.Files)
{
HttpPostedFileBase file = Request.Files[fileName];
//Save file content goes here
fName = file.FileName;
if (file != null && file.ContentLength > 0)
{
var originalDirectory = new DirectoryInfo(string.Format("{0}Images\\UploadImages", Server.MapPath(@"\")));
string pathString = System.IO.Path.Combine(originalDirectory.ToString(), "imagepath");
var myUniqueFileName = string.Format(@"{0}", Guid.NewGuid());
var fileName1 = Path.GetFileName(file.FileName);
var fileName2= Path.GetFileName(myUniqueFileName+file.FileName);
fileName2= fileName2.Replace("-", "");
bool isExists = System.IO.Directory.Exists(pathString);
file.FileName.Replace(fileName1, fileName2);
if (!isExists)
System.IO.Directory.CreateDirectory(pathString);
var path = string.Format("{0}\\{1}", pathString, fileName2);
file.SaveAs(path);
db.SPInsertPhotoTable(Convert.ToInt32(TempData["city"]), Convert.ToInt32(TempData["category"]), Convert.ToInt32(TempData["id"]), fileName2, "");
}
}
return View();
}