onchange can be detected by clicking Cancel on Chrome, but not on Firefox. If your project is only on mobile devices, you can try onchange like this. If you want to consider PC, you can bind an additional click event specifically for detection. When onchange is triggered, you can ignore click. When click is triggered, but onchange is not triggered or the same file is selected, it means that the user has not Change the file selection or click Cancel. . .
If I remember correctly, there will also be onChange when clicking cancel, and the value should be undefined.
onchange can be detected by clicking Cancel on Chrome, but not on Firefox. If your project is only on mobile devices, you can try onchange like this. If you want to consider PC, you can bind an additional click event specifically for detection. When onchange is triggered, you can ignore click. When click is triggered, but onchange is not triggered or the same file is selected, it means that the user has not Change the file selection or click Cancel. . .