清除bootstrap fileupload上的文件

时间:2013-11-19 08:11:18

标签: jquery

嗨我在文件上传时有这段代码

 <div class="span7">
     <div class="fileupload fileupload-new" data-provides="fileupload">
        <div class="input-append" style="width: 100%;">
           <div class="uneditable-input span4" style="width: 80%; height: 40px; line-height: 30px;">
             <i class="icon-file fileupload-exists" id="iconupload"></i>
             <span class="fileupload-preview"></span>
           </div>
           <span class="btn btn-file inputbutton btn-info btn-fileupload-medium">
           <span class="fileupload-new">Browse</span>
           <span class="fileupload-exists">Browse</span>
             <input type="file" id="fileXLS" name="fileXLS" />
           </span>
           <a href="#" id="removefile" class="btn fileupload-exists inputbutton btn-info" data-dismiss="fileupload">remove</a>
         </div>
     </div>
 </div>

有没有办法在不使用删除按钮的情况下使用jQuery处理上传后清除文件?

2 个答案:

答案 0 :(得分:6)

您在寻找.fileupload('clear')方法吗?

http://jasny.github.io/bootstrap/2.3.1/javascript.html#fileupload

向下滚动到“方法”部分

答案 1 :(得分:0)

您只需重置上传脚本成功回调中的值:

$('#fileXLS').val('');