Bootstrap-FileInput插件使用方法

/ 前端 / 没有评论 / 930浏览

页面引用

<link href="/resources/fileinput/css/fileinput.css" rel="stylesheet" type="text/css"/>
<script src="/resources/fileinput/js/fileinput.js" type="text/javascript"></script>
<script src="/resources/fileinput/js/locales/zh.js" type="text/javascript"></script>

JavaScript

$(function () {
        var id = '${lid}';
        $('#file-zh').fileinput({
            language: 'zh',
            uploadUrl: '/loan/upload/' + id + '.shtml',
            showPreview: false,
            elErrorContainer: "#fileError",
            browseClass: "btn btn-success btn-file btn-sm",
            browseLabel: "查找文件",
            browseIcon: '<i class="glyphicon glyphicon-search"></i>',
            removeClass: "btn btn-danger btn-file btn-sm",
            removeLabel: "清除",
            removeIcon: '<i class="glyphicon glyphicon-trash"></i>',
            uploadClass: "btn btn-info btn-file btn-sm",
            uploadLabel: "上传",
            uploadIcon: '<i class="glyphicon glyphicon-upload"></i>'
        })
            .on("fileuploaded", function (e, data) {
                var res = data.response;
                if (res.code == 200) {
                    location.href = res.url;
                }
            });
    })