After selecting the file for the first time, click the button again. After the dialog box pops up, you do not select the file but choose to cancel. The file selected for the first time is gone. . . Showing no files selected
歡迎選擇我的課程,讓我們一起見證您的進(jìn)步~~
If you have special needs, you can use a temporary variable to save the value of the last operation, for example, after the file selection event is triggered
var prevFile = null;
fileElement.onchange = function(){
var file = fileElement.files[0] || prevFile;
if(!file) return false;
///此處省略一大段邏輯///
prevFile = file;
};