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 8679991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:08:05+00:00 2026-06-12T21:08:05+00:00

Hi all i ma working on mvc4 i had uploaded single image (file) but

  • 0

Hi all i ma working on mvc4 i had uploaded single image (file) but now i need to uoload more than 100 files(images) at time to my application how could i do this plz help to do this

here my code:
this is my controllers

[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);
                    string thumbPath = Path.Combine(imagesPath, "Thu" + fileName);
                    string fullPath = Path.Combine(imagesPath, "Full" + fileName);
                    string Bigpath = Path.Combine(imagesPath, "big" + fileName);
                    string Bigpatha = Path.Combine(imagesPath, "biga" + fileName);
                    string Bigpathb = Path.Combine(imagesPath, "bigb" + fileName);
                    string Bigpathc = Path.Combine(imagesPath, "bigc" + fileName );
                    ImageModel.ResizeAndSave(thumsise, fileName, model.ImageUploaded.InputStream, 80, true);
                    ImageModel.ResizeAndSave(thumbPath, fileName, model.ImageUploaded.InputStream, 100, true);
                    ImageModel.ResizeAndSave(fullPath, fileName, model.ImageUploaded.InputStream, 500, true);
                    ImageModel.ResizeAndSave(Bigpath, fileName, model.ImageUploaded.InputStream, 200, true);
                    ImageModel.ResizeAndSave(Bigpatha, fileName, model.ImageUploaded.InputStream, 250, true);
                    ImageModel.ResizeAndSave(Bigpathb, fileName, model.ImageUploaded.InputStream, 150, true);
                    ImageModel.ResizeAndSave(Bigpathc, fileName, model.ImageUploaded.InputStream, 50, true);
                }
                return View("Upload",model);
            }

this my class file:

public class ImageModel
    {

        [Required]

        public HttpPostedFileWrapper ImageUploaded { get; set; }
        public static void ResizeAndSave(string savePath, string fileName, Stream imageBuffer, int maxSideSize, bool makeItSquare)
        {
            int newWidth;
            int newHeight;
            Image image = Image.FromStream(imageBuffer);
            int oldWidth = image.Width;
            int oldHeight = image.Height;
            Bitmap newImage;
            if (makeItSquare)
            {
                int smallerSide = oldWidth >= oldHeight ? oldHeight : oldWidth;
                double coeficient = maxSideSize / (double)smallerSide;
                newWidth = Convert.ToInt32(coeficient * oldWidth);
                newHeight = Convert.ToInt32(coeficient * oldHeight);
                Bitmap tempImage = new Bitmap(image, newWidth, newHeight);
                int cropX = (newWidth - maxSideSize) / 2;
                int cropY = (newHeight - maxSideSize) / 2;
                newImage = new Bitmap(maxSideSize, maxSideSize);
                Graphics tempGraphic = Graphics.FromImage(newImage);
                tempGraphic.SmoothingMode = SmoothingMode.AntiAlias;
                tempGraphic.InterpolationMode = InterpolationMode.HighQualityBicubic;
                tempGraphic.PixelOffsetMode = PixelOffsetMode.HighQuality;
                tempGraphic.DrawImage(tempImage, new Rectangle(0, 0, maxSideSize, maxSideSize), cropX, cropY, maxSideSize, maxSideSize, GraphicsUnit.Pixel);
            }
            else
            {
                int maxSide = oldWidth >= oldHeight ? oldWidth : oldHeight;

                if (maxSide > maxSideSize)
                {
                    double coeficient = maxSideSize / (double)maxSide;
                    newWidth = Convert.ToInt32(coeficient * oldWidth);
                    newHeight = Convert.ToInt32(coeficient * oldHeight);
                }
                else
                {
                    newWidth = oldWidth;
                    newHeight = oldHeight;
                }
                newImage = new Bitmap(image, newWidth, newHeight);
            }
            newImage.Save(savePath + fileName + ".jpg", ImageFormat.Jpeg);
            //newImage.Save(savePath + fileName + ".jpg", ImageFormat.Jpeg);
            image.Dispose();
            newImage.Dispose();
        }  
    }
}

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 u help me to upload more than 100 files at a time 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-12T21:08:06+00:00Added an answer on June 12, 2026 at 9:08 pm

    The view is OK. The problem is the controller: don’t use ImageModel to get the file from the form. It restricts you to just one file. You can get multiple files through Request.Files property:

                for (int i = 0; i < Request.Files.Count; i++)
                {
                    if (Request.Files[i].ContentLength > 0)
                    {
                        HttpPostedFileBase uploadedFile = Request.Files[i];
                        ... here you can use the resize and other logic 
                        ... on uploadedFile.InputStream
                    }
                }
    

    Check the HttpPostedFileBase class. It’s the base class for HttpPostedFileWrapper which you use in your ImageModel model class.

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

Sidebar

Related Questions

Hi all I am working on MVC4. I have uploaded a single image file,
They were all working fine on my XAMMP sandbox but now nothing. Something im
I'm uploading a file, all working fine, but I want to set a time
i have uploaded a video to django and it's all working fine .. but
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
My wordpress*(a custom template)* nav is all working on all of the pages but
i have a gridview with search option by a database table.All working fine but
I'm having a trouble, making Ninject and WebAPI.All working together. I'll be more specific:
I'm trying to write a 2d array into an output file, it's all working

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.