Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8679471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:58:52+00:00 2026-06-12T20:58:52+00:00

Hi all I am working on MVC4. I have uploaded a single image file,

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T20:58:53+00:00Added an answer on June 12, 2026 at 8:58 pm

    How about writing a for loop:

    [HttpPost]
    public ActionResult Uploading(ImageModel model)
    {
        if (ModelState.IsValid)
        {     
            string imagesPath = Server.MapPath("~/Content/Images");
            string fileName = Guid.NewGuid().ToString();
            for (var i = 1; i <= 100; i++) 
            {
                string thumsise = Path.Combine(
                    imagesPath, 
                    string.Format("Thumb{0}_{1}", fileName, i)
                );
                ImageModel.ResizeAndSave(thumsise, fileName, model.ImageUploaded.InputStream, 80, true);
            }
            return View("Upload",model);
        }
    }
    

    This will create 100 images in the ~/Content/Images folder by prefixing the Guid with Thumb and by suffixing it with the index of the loop.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi all i ma working on mvc4 i had uploaded single image (file) but
i have uploaded a video to django and it's all working fine .. but
They were all working fine on my XAMMP sandbox but now nothing. Something im
i have a gridview with search option by a database table.All working fine but
I'm uploading a file, all working fine, but I want to set a time
I'm writing a PDF file directly from code, it's all working nicely, but I
folks it was all working fine few day ago. But now i am getting
We have three developers and one tester all working against the same database. We
My wordpress*(a custom template)* nav is all working on all of the pages but
I have a draggable table which all working fine, though I want to be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.