LayUI表单上传文件

LayUI,上传文件携带参数。
图片
前端:

<div class="layui-form" style="width: 700px;margin-top: 10px">
    <div class="layui-form-item">
        <label class="layui-form-label">包名</label>
        <div class="layui-input-block">
            <input type="text" id="packageName" required lay-verify="required" placeholder="请输入包名"
                   autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">版本名</label>
        <div class="layui-input-block">
            <input type="text" id="versionName" required lay-verify="required" placeholder="请输入版本名"
                   autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">版本号</label>
        <div class="layui-input-block">
            <input type="number" id="versionCode" required lay-verify="required" placeholder="请输入版本号"
                   autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">平台</label>
        <div class="layui-input-block">
            <select id="type" lay-verify="required">
                <option value="1">Android</option>
                <option value="2">IOS</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">强制更新</label>
        <div class="layui-input-block" id="isForce">
            <input type="radio" name="force" value="1" title="">
            <input type="radio" name="force" value="0" title="" checked>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">上传文件</label>
        <div class="layui-input-inline uploadHeadImage">
            <div class="layui-upload-drag" id="uploadFile">
                <i class="layui-icon"></i>
                <p>点击上传文件,或将文件拖拽到此处!</p>
            </div>
        </div>
        <div class="layui-input-inline">
            <div id="uploadResult" class="layui-upload-list">

            </div>
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">升级说明</label>
        <div class="layui-input-block">
            <textarea id="desc" lay-verify="required" placeholder="请输入内容" class="layui-textarea"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" id="commit" lay-submit lay-filter="formDemo">立即提交</button>
            <button id="cancel" class="layui-btn layui-btn-primary">返回</button>
        </div>
    </div>
</div>

js:

var uploadInst = upload.render({
            elem: '#uploadFile'
            , url: '/orgmanage/application/upload'
            , headers: {authorization: token}
            , size: 1024 * 50
            , accept: 'file'
            , multiple: true
            , auto: false
            , bindAction: '#commit'
            , before: function () {
                this.data = {
                    packageName: $('#packageName').val(),
                    versionName: $('#versionName').val(),
                    versionCode: $('#versionCode').val(),
                    type: $('#type').val(),
                    isForceUpdate: $('#isForce input[name="force"]:checked ').val(),
                    updateDetail: $('#desc').val()
                };

                var index = layer.msg('上传中..', {
                    icon: 16
                    , shade: 0.5
                    , time: false
                });

            }
            , done: function (res, index, upload) {
                layer.close(index);
                if (res.code == 0) {
                    layer.msg(res.msg)
                    reloadTable();
                    $('.org_table_div').show();
                    $('#uploadImg').hide();
                    clear()
                } else
                this.error(index, upload);
            }
            , error: function (index, upload) {
                layer.msg("上传失败")
            }
        });

携带参数就是这个样子携带的。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值