How to keep the last selected file when deselecting <input type="file">
天蓬老师
天蓬老师 2017-07-05 11:08:02
0
2
1930

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

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(2)
我想大声告诉你

Try this https://stackoverflow.com/que...

刘奇

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;
};
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!