Clone a file input element in Javascript

后端 未结 4 1535
囚心锁ツ
囚心锁ツ 2020-11-28 11:55

I have a file input element that needs to be cloned after the user has browsed and selected a file to upload. I started by using obj.cloneNode() and everything worked fine,

4条回答
  •  孤独总比滥情好
    2020-11-28 12:36

    Editing the file form field is a security risk and thus is disabled on most browsers and should be disabled on firefox. It is not a good idea to rely on this feature. Imagine if somebody was able, using javascript, to change a hidden file upload field to, lets say,

    c:\Users\Person\Documents\Finances

    Or

    C:\Users\Person\AppData\Microsoft\Outlook.pst

    :)

提交回复
热议问题