常错的地方在此留痕

    layui.use(['form', 'layer','element','upload'], function () {
    var $ = layui.jquery;
    var layer = layui.layer;
    var form = layui.form;
    var upload = layui.upload;

    //选完文件后不自动上传
    upload.render({
        elem: '#student-upload-change',
        url: '你的后台api接口',
        accept: 'file', //普通文件
        exts: 'xls|xlsx', //只允许上传excel文件
        auto: false, //是否自动上传
        field: 'student-upload-change', //重点:后台验证的表单名称
        //multiple: true,
        bindAction: '#student-upload-change-action',
        done: function(res){
            if (200 === res.code) {
                layer.msg(res.msg, {icon: 1});
            } else {
                layer.msg(res.msg, {icon: 2});
            }
        },
        error: function () {
            //请求异常回调
        }
    });

标签: layui upload

添加新评论