Restoring the value of a input type=file after failed validation

前端 未结 1 922
暗喜
暗喜 2020-11-30 13:30

I have a form with several inputs that deal with files. The javascript validation is pretty good at checking to make sure that everything is good, but some things require PH

相关标签:
1条回答
  • 2020-11-30 14:20

    You cannot populate the file input, to do so would be a serious security problem.

    Instead, store the uploaded content on the server and store an id that you can use to reference it in a hidden input.

    Clean the files up automatically after they reach a certain age, and provide a means for the user to change their mind about what file they want to upload (e.g. a checkbox (checked by default) for each file being stored on the server for upload)

    0 讨论(0)
提交回复
热议问题