Layui 先选文件再上传,且带参数

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xinyuebaihe/article/details/88666931
layui.use('upload', function() {
        var $ = layui.jquery, upload = layui.upload;
        //选完文件后不自动上传
        upload.render({
            elem: '#test8'
            , url: '/seal/contract/upload'
            , auto: false
			,accept:"file"
			,size: 50*1024
			/*,ext:"file"*/
            //,multiple: true
            , bindAction: '#test9'
            ,before: function(obj){
                layer.load(); //上传loading
                this.data={'id':$("#id").val()};
            }
            , done: function (res) {
                closePage(res);
                //console.log(res);
            }
        });
    })

https://www.layui.com/demo/upload.html

before:可以添加上传参数

accept:file为可以上传任何文件。

accept 指定允许上传时校验的文件类型,可选值有:images(图片)、file(所有文件)、video(视频)、audio(音频) string images
exts 允许上传的文件后缀。一般结合 accept 参数类设定。假设 accept 为 file 类型时,那么你设置 exts: 'zip|rar|7z' 即代表只允许上传压缩格式的文件。如果 accept 未设定,那么限制的就是图片的文件格式 string jpg|png|gif|bmp|jpeg

详见:https://www.layui.com/doc/modules/upload.html

猜你喜欢

转载自blog.csdn.net/xinyuebaihe/article/details/88666931
今日推荐