how to change the file input's filelist

前端 未结 2 845
慢半拍i
慢半拍i 2021-01-04 23:45

I have this input of type \"file\", and I want to change its files list. Example:



        
相关标签:
2条回答
  • 2021-01-05 00:25

    For security reasons, browsers prevent javascript from changing the files which will be uploaded: only the user can select files via the user interface. This is to prevent an evil script to upload /etc/passwd, for example, without the user knowing.

    The one exception is that calling "reset" on the form will clear the file or filelist, but you can never add to programmatically.

    0 讨论(0)
  • 2021-01-05 00:29

    What you want is using the multiple attribute on the input element. That way, in newer browsers user will be able to select multiple files to upload.

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