Solve the problem of invalid second upload of the same file with input type=file

When uploading files, everyone will introduce the input tag. However, during the implementation process, after uploading a file, the upload code will not be triggered when the same file is uploaded for the second time. The problem is actually solved in this way.

Or when uploading pictures, there will be a limit on the size of the picture. If the first picture is smaller than the size we set, there will be a prompt, but when we upload the same picture for the second time, no prompt will appear.

Wait...the above two situations are encountered

Solution

 The implementation method is just one sentence: event.target.value = ''

Because the trigger condition is change, the function will not be entered when the file stored in the input has not changed, so at the end of the upload, just clear the value in the input.

Guess you like

Origin blog.csdn.net/m0_63873004/article/details/130203507