【发布时间】:2012-10-05 07:37:00
【问题描述】:
大家好,我正在研究 MVC4。我已经上传了一个图像文件,它保存在目标文件夹中,但现在我需要一个循环,以便将图像保存超过 100 次。
这是我的代码,
这是我的控制器:
[HttpPost]
public ActionResult Uploading(ImageModel model)
{
if (ModelState.IsValid)
{
string fileName = Guid.NewGuid().ToString();
string serverPath = Server.MapPath("~");
string imagesPath = serverPath + "Content\\Images\\";
string thumsise = Path.Combine(imagesPath, "Thumb" + fileName);
ImageModel.ResizeAndSave(thumsise, fileName, model.ImageUploaded.InputStream, 80, true);
}
return View("Upload",model);
}
这是我的索引页:
@using (Html.BeginForm("Uploading", "Upload", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<input type="file" name="ImageUploaded" id="btnUpload" multiple="multiple" accept="image/*" />
<button type="submit" id="Upload">Upload</button>
<br />
}
你能帮我做这件事吗?提前致谢。
【问题讨论】:
-
为什么要将同一张图片保存 100 次?
-
其实需要找到loop的时间耗时
-
1 次或 100 次循环的时间?仍然不明白为什么你需要一个 100
-
谢谢mr.dove你花时间帮我完成任务
标签: image image-processing file-upload for-loop asp.net-mvc-4