文件上传组件使用。
Posted abcyrf
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了文件上传组件使用。相关的知识,希望对你有一定的参考价值。
参考:
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)
以上是关于文件上传组件使用。的主要内容,如果未能解决你的问题,请参考以下文章
已解决在react+ts中 atnd 用 upload 组件报错Failed to execute ‘readAsArrayBuffer,param 1 is notof type Blob(代码片段
已解决在react+ts中 atnd 用 upload 组件报错Failed to execute ‘readAsArrayBuffer,param 1 is notof type Blob(代码片段