Add a File (JS object) to input type=“file”

前端 未结 1 1786
不知归路
不知归路 2020-12-21 23:15

I need a way to add a File object to a file input field.

Note that I do not want to set the value of the file field. (which is a security risk, ...

相关标签:
1条回答
  • 2020-12-22 00:00

    No, you can't.

    Taken from here:

    It seems like you want to take the File object from the drop event and assign it to the element. Unfortunately, you can't do that. Only the user can select files; you can't dynamically change the files which will be uploaded because browsers deny JavaScript this ability for security reasons.

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