How do I submit a “file” input without submit button using JavaScript?

前端 未结 5 1646
栀梦
栀梦 2020-12-29 02:27

There is a way to automatically submit a form without clicking to a \"submit\" button?

I have a form with one \"file\" input. I would submit the form after the user

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-29 03:05

    Yes, you can add the following to the onchange event of the file input:

    
    

    this submits the form right after the user has picked a file. However, the user can't correct a mistaken selection before submitting - be sure to check whether this is really wise.

提交回复
热议问题