Second use of input file doesn't trigger onchange anymore

前端 未结 8 1433
旧巷少年郎
旧巷少年郎 2020-12-25 11:55

I have a picture upload button that automatically uploads the file when selected from the browse window.
Nonetheless, it doesn\'t work the second time around and that is

8条回答
  •  滥情空心
    2020-12-25 12:37

    My guess is that you test your functionality with the same picture file over and over again.

    If you select the same file, the onChange event of input[type=file] will not fire.

    Different file with the same name would not fire the event as well. Select a different image file - it will happen.

    To avoid this you can reset the form to ensure that choosing a file will be performed on a clean file control

提交回复
热议问题