Store form files after validation error

I have a form where I simultaneously send several (say 10) files to the backend along with some other regular input fields.

When I find the verification problem in the backend, I show the form again and fill in the usual inputs (drop-down lists, text inputs, etc.), but I can’t fill in the file fields, forcing the user to select files from the file again.

The solution I think of is sending the base64 encoded view of the files and returning them to the form in case of a validation error, but I would like to know if there is an easier way.

+4
source share
3 answers

, , . (, - ). ( ), Base64, AJAX, .

  • : ( ) JS. , ... (, ...)
  • . .
  • . , . AJAX, .

, !

+1

:

1) (javascript/jquery)

2) , .

. , ajax (1) (2). , ,

0

, , .

.

When processing a request: if the file in the request receives the file (and saves it if the form is not valid), otherwise, if the identifier file receives the file from the repository.

0
source

Source: https://habr.com/ru/post/1663944/


All Articles