I\'ve got a simple form in an MVC app I\'ve made. It contains a file field so users can upload an image. It all works great.
Problem is, if the form submit fails val
You cannot set the value of a HTML file input box. As a workaround, replace the file upload box with a hidden input field when outputting the form after validation.
On submission, you populate the hidden field with the value from the file input box (to be resubmitted later). Remember to have either the file upload or hidden field name present at any one time (not both):
Note: The code below is for illustration/explanation purposes only. Replace it with the code appropriate to the language you use.