bootstrap上传插件fileinput功能非常强大,本文给出一例自动上传上传成功回调的用例.核心就是调用filebatchselected文件选择完成事件实现的,文件上传成功的事件是fileuploaded. 注意插件版本是
注意插件版本是 version 4.2.7 .
1. [代码][JavaScript]代码
<script> $("#update_csv").fileinput({ showUpload: false, language:'zh', uploadAsync:true, dropZoneEnabled:false, uploadUrl:'http://www.soyiyuan.com/', maxFileCount: 1, maxImageWidth: 600, resizeImage: false, showCaption: false, showPreview: false, browseClass: "btn btn-primary btn-lg", allowedFileExtensions : ['csv', 'txt'], previewFileIcon: "" }).on("filebatchselected", function(event, files) { $(this).fileinput("upload"); }) .on("fileuploaded", function(event, data) { if(data.response) { alert('处理成功'); } }); </script>