我如何“取消选择”选定的文件? [英] How do I 'unselect' a selected file?
本文介绍了我如何“取消选择”选定的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用这个允许用户选择和上传文件:
I'm using this to allow the user to select and upload a file:
<input id="fileInput" type="file" ng-file-select="onFileSelect($files)">
这正确显示:
当用户点击上传,我上传的文件。
When user clicks 'Upload', I upload the file.
当用户点击删除,我如何清除的文件名?
When the user clicks 'Remove', how do I clear out the file name?
推荐答案
只需清除文件输入元素的值:
Simply clear the value of the file input element:
document.getElementById('remove').addEventListener('click', function () {
document.getElementById('fileInput').value = ''
});
下面是一个演示
这篇关于我如何“取消选择”选定的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文