码迷,mamicode.com
首页 > Web开发 > 详细

文件上传组件使用。

时间:2018-09-07 13:53:44      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:end   document   text   files   src   index   tps   asi   show   

参考:
https://www.cnblogs.com/landeanfen/p/5007400.html

bootstrap-fileinput源码:https://github.com/kartik-v/bootstrap-fileinput

bootstrap-fileinput在线API:http://plugins.krajee.com/file-input

bootstrap-fileinput Demo展示:http://plugins.krajee.com/file-basic-usage-demo


<script src="/static/vendors/kartik-v-bootstrap-fileinput-3540936/js/plugins/piexif.min.js"
        type="text/javascript"></script>
<script src="/static/vendors/kartik-v-bootstrap-fileinput-3540936/js/plugins/sortable.min.js"
        type="text/javascript"></script>
<script src="/static/vendors/kartik-v-bootstrap-fileinput-3540936/js/plugins/purify.min.js"
        type="text/javascript"></script>
<script type="text/javascript" src="/static/vendors/kartik-v-bootstrap-fileinput-3540936/js/fileinput.min.js"></script>
 <form id="fileuploadform" enctype="multipart/form-data">

                                <div class="col-md-12 col-sm-12 col-xs-12 form-group has-feedback">
                                    <label class="control-label col-md-3 col-sm-12 col-xs-12"
                                    >选择文件</label>
                                    <div class="col-md-9 col-sm-12 col-xs-12">
                                        <input id="input-id" type="file">
                                    </div>
                                </div>

$(document).ready(function () {

    $("#input-id").fileinput({
        showUpload:true,
        uploadLabel: "xxx",
        uploadTitle: "xxxx",
        allowedFileExtensions: [‘xlsx‘],
        maxFileSize: 10000,
        maxFilesNum: 1,
        uploadUrl:  "xxxx",
        //showPreview:false,
        enctype: ‘multipart/form-data‘,
        ajaxSettings: { type: "POST",   headers: header,},

        uploadExtraData: function (previewId, index) {
            var obj = {};
           obj["xxx"]=$("#xxx").val()
            return obj;
        },

     });

   

 });
 perfFile = request.FILES.get("file_data", None)  # 获取上传的文件,如果没有文件,则默认为None
    if not perfFile:
        result["error"] = "no uploaded files found"
        return Response(result)

文件上传组件使用。

标签:end   document   text   files   src   index   tps   asi   show   

原文地址:https://www.cnblogs.com/abcyrf/p/9603646.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!