Re-uploading a file with AJAX after it was changed causes net::ERR_UPLOAD_FILE_CHANGED in Chrome

后端 未结 6 1759
悲&欢浪女
悲&欢浪女 2021-02-02 18:32

I have a simple HTML form that sends an selected file via AJAX to an API endpoint.

If I do the following steps:

  1. Press the Upload button and make an POST r
6条回答
  •  爱一瞬间的悲伤
    2021-02-02 18:58

    $("#id_of_your_file_input").click(function(){
     $("#id_of_your_file_input").val('');
    });
    

    Just add the above jQuery script to handle this browser exception. What it does is clearing the file input every time someone clicks on it, so that it will remove the current selection.

提交回复
热议问题