Hi all I am working on MVC4. I have uploaded a single image file, it is saved in the destination folder, but now I need a loop so that image the is saved more than 100 times.
Here is my code,
This is my controller:
[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);
}
and this is my index page:
@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 />
}
Could you please help me to do this? Thanks in advance.
How about writing a
forloop:This will create 100 images in the
~/Content/Imagesfolder by prefixing the Guid withThumband by suffixing it with the index of the loop.