Announcement Announcement Module
Collapse
No announcement yet.
Display file name on validation error Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Display file name on validation error

    I am not sure this is possible due to how <input type="file"> works, but I thought to double check.

    I have, in my form, along with other values a file to upload. The user writes the fields, selects a file to upload and presses submit. The file itself is not part of the command object.

    If there are no validation errors, everything works great. If there are validation errors, the form is returned along with the values the user entered. However, the name/path of the file he/she selected is lost. I would like to retain this if there is an error. Not so much the actual uploaded file - I just do not want to make the user search for the file again.

    My guess is this is not possible - but maybe someone tried this before and have a solution?

  • #2
    There isn't a way to set the contents of a file input field. Can't do it in html or in javascript (for security reasons -- hey, let's auto-upload /etc/passwd!). So, no, there isn't a simple way to do this.

    You can move uploads into a plugin like Flash or ActiveX or Silverlight or some such, and could maybe have Spring insert the previous filename into a hidden field that the plugin-based solution could read from. Probably more trouble than it's worth (and more browser-dependent too, of course).

    Comment

    Working...
    X