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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:46:50+00:00 2026-06-12T01:46:50+00:00

When I attempt to upload images to my MVC controller action and there is

  • 0

When I attempt to upload images to my MVC controller action and there is a validation error, I have to click through each of the buttons and find all of my files again.

If I have a view that consists of

<input type="file" id="file0" name="Files[0]" />
<input type="file" id="file1" name="Files[1]" />

and a controller action like

public ActionResult Create(ModelClass model, IEnumerable<HttpPostedFileBase> Files)
{
    if(ModelState.IsValid)
    {
        //do work
        if(PhotoValidation.IsValid(Files))
        {
            //do work
        }
        else 
        {
            ModelState.AddModelError("","Photos not valid");
        }
    }
    return view(model); // Way to return photos back to the view on modelstate error?
}

The files get posted to the server fine but if there is a model validation error, is there any way to return the model AND the Files so the user doesn’t have to upload them again?

  • 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-12T01:46:52+00:00Added an answer on June 12, 2026 at 1:46 am

    This is not possible. The value of a intput type=”file” is never used on parsing an HTML page. That’s a huge security risk, so no modern browser will allow them to ‘retain’ values.

    If you are sure that your clients are using browser with HTML5 support, you can try using JavaScript File API in order to eliminate postbacks – check following articles:

    • Working with files in JavaScript, Part 1: The Basics
    • Working with files in JavaScript, Part 2: FileReader
    • Working with files in JavaScript, Part 3: Progress events and errors
    • Working with files in JavaScript, Part 4: Object URLs
    • Working with files in JavaScript, Part 5: Blobs
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is a controller action method that I have to upload a user's profile
I have installed the Paperclip plugin to attempt to upload an avatar for my
I have an upload phone app that uploads either images or audio recordings. The
I have an Upload model - contains images uploaded by the user. Within the
I am using the following code, upload.php, to try to have someone upload a
I am using CloudMailin in an attempt to upload profile pics to a mobile
My Asp.net MVC app requires a file upload. In the course of the upload
I am using the Copy web service to attempt to upload a document to
I have and issue binding to my model with an action filter using reflection.
I am using WebTechNick's file upload plugin to save images on my CakePHP site.

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.