以下是一个简单的ASP.NET MVC图片编辑的解决方案示例:
public ActionResult Index()
{
// 获取Images文件夹中的所有图片文件
string[] imageFiles = Directory.GetFiles(Server.MapPath("~/Images"));
// 将图片文件列表传递给视图
return View(imageFiles);
}
@model string[]
@foreach (var imagePath in Model)
{
}
public ActionResult Edit(string imagePath)
{
// 获取要编辑的图片路径
string fullImagePath = Server.MapPath(imagePath);
// 将图片路径传递给视图
ViewBag.ImagePath = imagePath;
return View();
}
@{
Layout = null;
}
@using (Html.BeginForm("Save", "Image", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
}
[HttpPost]
public ActionResult Save(HttpPostedFileBase imageFile, string imagePath)
{
// 获取要保存的图片路径
string fullImagePath = Server.MapPath(imagePath);
// 保存上传的图片
imageFile.SaveAs(fullImagePath);
// 重定向到编辑页面
return RedirectToAction("Edit", new { imagePath = imagePath });
}
这是一个简单的ASP.NET MVC图片编辑的解决方案示例。你可以根据实际需求进行修改和扩展。