Bootstrap fileinput图片上传 jquery
2020-06-24 11:59
260 查看
上传图片元素显示
先引用js css,js css可以在网上进行下载使用
<link href="../../UI/Style/fileinput.css" rel="stylesheet" /> <script src="../../UI/Scripts/fileinput.js"></script> <script src="../../UI/Scripts/locales/zh.js"></script> <div class="container kv-main" style="width:850px;"> <input id="file-1" name="file-zh" class="file-loading" type="file" data- preview-file-type="any"> </div>
首先fileinputs()函数方法需要初始化
$(function(){ fileinputs() })
//上传图片使用方法
function fileinputs() { $("#file-1").fileinput({ uploadUrl: "http://192.168.1.188:3384/Page/ERP/Attachment.aspx?action=addInfo", //此处调用的就是接口 allowedFileExtensions: ['jpg', 'png', 'gif', 'BMP'], //可上传的图片类型,也可以写其他的类型,这里根据自己的需求 maxFileSize: 0, language: 'zh', uploadLabel: "上传附件", browseLabel: '选择附件', browseClass: "layui-btn", //这里使用的layui里的按钮如果不是使用的layui框架可以删除 // 浏览按钮样式 uploadClass: "layui-btn",// 这里使用的layui里的按钮如果不是使用的layui框架可以删除 layoutTemplates: { actionUpload: '',//去除上传预览缩略图中的上传图片 actionDownload: '', //去除上传预览缩略图中的下载图标 }, uploadExtraData: function (previewId, index) { //额外参数的关键点 var obj = {}; obj.FDesc = $('#Duty').val(); obj.FSenderID = $('#userinfo').attr('data-usercode'); obj.FSourceBillNo = fbillnoFile; obj.FTypeID = 2; return obj; //这个函数方法里就是你要传的参数格式 }, }).on("fileuploaded", function (event, data, previewId, index) {//该方法将在上传之前触发 //console.log(data.response); var result = data.response; //后台返回的json if (result.errcode == "0") { dialog.promptNoCancle('上传成功', result.errmsg, 'success', function (s) { $('#file-1').fileinput('refresh', {});//清空记录 }); // 这里使用的是弹窗,根据自己的需求设定 } else { alert('上传失败') } }).on('fileerror', function (event, data, previewId, index) { //该方法将在上传出現異常触发 //console.log(data.jqXHR.responseText); }); }
相关文章推荐
- bootstrap fileinput组件整合Springmvc上传图片到本地磁盘
- BootStrap使用file-input插件上传图片的方法
- bootstrap 文件上传插件 fileinput.min.js 可以预览图片
- Bootstrap fileinput的图片上传 java框架基于springMVC
- bootstrap fileinput之手机图片上传显示旋转问题
- bootstrap 上传图片插件 file-input 的简单使用
- bootstrap 上传图片插件 file-input 的简单使用
- Bootstrap FileInput上传图片API解释(二)
- 使用bootstrap图片上传插件(fileInput)springmvc实现图片上传全流程
- Bootstrap中的fileinput 多图片上传及编辑功能
- django 通过bootstrap fileinput 上传图片
- bootstrap-fileinput,多图片上传踩过的坑
- Bootstrap文件(图片)上传插件File Input进阶使用说明
- Bootstrap-fileinput 多图片上传编辑
- Bootstrap框架---krajee插件fileinput--最好用的文件上传组件----单多张图片上传交互方式三(推荐)
- Bootstrap fileinput 上传Excel附带图片展示
- jquery-fileupload IE8IE9无法上传图片的BUG及如何给input[type=file]自定义样式
- Bootstrap FileInput插件上传图片和文件
- bootstrap fileinput 组件整合SpringMVC上传图片到本地磁盘
- bootstrap fileinput 组件整合SpringMVC上传图片到本地磁盘