關於bootstrap-fileinput上傳后刪除選中上傳的文件,回到最初的選擇文件界面


在網上找了很多,沒有找到bootstrap-fileinput自己定義的相關處理方法。於是投機取巧一下。

找到選擇文件后的顯示的刪除按鈕。

<button type="button" class="kv-file-remove btn btn-xs btn-default" title="刪除文件"><i class="glyphicon glyphicon-trash text-danger"></i></button>

然后在file上傳成功的事件里面處理。

//導入文件上傳完成之后的事件
$("#txt_File").on("fileuploaded", function (event, data, previewId, index) {
if (data.response.result == "NO") {
toastr.error(data.response.Msg);
console.log(event);
$(".kv-file-remove").click();  //手動調用刪除文件按鈕的click方法
} else {
toastr.success("上傳成功");
}

});


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM