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

后端 未结 6 1679
悲&欢浪女
悲&欢浪女 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:42

    I would just check file.lastModified between the upload button clicks and if different reset the form values.

    https://developer.mozilla.org/en-US/docs/Web/API/File/lastModified

    A better solution would be to read the file into an ArrayBuffer and upload that.

提交回复
热议问题