Bootstrap FileInput 上传  中文 API 整理

上传插件有很多 但是公司用的就是 Bootstrap FileInput

自己就看了看  会用就行

自己都不知道每个值是干嘛用的就问大佬

总结一下

  1. 一、 引入文件
  2. <link href="../css/bootstrap.min.css"rel="stylesheet">
  3. <link href="../css/fileinput.css" media="all"rel="stylesheet" type="text/css" />
  4. <scriptsrc="../js/jquery-2.0.3.min.js"></script>
  5. <script src="../js/fileinput.js"type="text/javascript"></script>
  6. <script src="../js/bootstrap.min.js"type="text/javascript"></script>
  7. 二、 初始化设置:
  8. $("#uploadfile").fileinput({
  9. language: 'zh', //设置语言
  10. uploadUrl:"http://127.0.0.1/testDemo/fileupload/upload.do", //上传的地址
  11. allowedFileExtensions: ['jpg', 'gif', 'png'],//接收的文件后缀
  12. //uploadExtraData:{"id": 1, "fileName":'123.mp3'},
  13. uploadAsync: true, //默认异步上传
  14. showUpload:true, //是否显示上传按钮
  15. showRemove :true, //显示移除按钮
  16. showPreview :true, //是否显示预览
  17. showCaption:false,//是否显示标题
  18. browseClass:"btn btn-primary", //按钮样式
  19. dropZoneEnabled: false,//是否显示拖拽区域
  20. //minImageWidth: 50, //图片的最小宽度
  21. //minImageHeight: 50,//图片的最小高度
  22. //maxImageWidth: 1000,//图片的最大宽度
  23. //maxImageHeight: 1000,//图片的最大高度
  24. //maxFileSize:0,//单位为kb,如果为0表示不限制文件大小
  25. //minFileCount: 0,
  26. maxFileCount:10, //表示允许同时上传的最大文件个数
  27. enctype:'multipart/form-data',
  28. validateInitialCount:true,
  29. previewFileIcon: "<iclass='glyphicon glyphicon-king'></i>",
  30. msgFilesTooMany: "选择上传的文件数量({n}) 超过允许的最大数值{m}!",
  31. }).on("fileuploaded", function (event, data, previewId, index){
  32.  
  33. });
  1. 属性名 属性类型 描述说明 默认值
  2. language String                        多语言设置,使用时需提前引入\locales文件夹下对应的语言文件,中文zh,引入语言文件必须放在fileinput.js之后 'en'
  3. showCaption Boolean 是否显示被选文件的简介 true
  4. showBrowse Boolean 是否显示浏览按钮 true
  5. showPreview Boolean 是否显示预览区域 true
  6. showRemove Boolean 是否显示移除按钮 true,
  7. showUpload Boolean 是否显示上传按钮 true,
  8. showCancel Boolean 是否显示取消按钮 true,
  9. showClose: Boolean 是否显示关闭按钮 true
  10. showUploadedThumbs Boolean   true
  11. browseOnZoneClick Boolean   false
  12. autoReplace Boolean 是否自动替换当前图片,设置为true时,再次选择文件, 会将当前的文件替换掉。 false
  13. generateFileId Object   null
  14. previewClass String 添加预览按钮的类属性 ‘’
  15. captionClass String   ‘’
  16. frameClass String   'krajee-default'
  17. mainClass String   'file-caption-main'
  18. mainTemplate Object   null
  19. purifyHtml Boolean   true
  20. fileSizeGetter Object   null
  21. initialCaption String   ''
  22. initialPreview Array/Object   []
  23. initialPreviewDelimiter String   '*$$*'
  24. initialPreviewAsData Boolean   false
  25. initialPreviewFileType String   'image'
  26. initialPreviewConfig Array/Object   []
  27. initialPreviewThumbTags Array/Object   []
  28. previewThumbTags Object   {}
  29. initialPreviewShowDelete Boolean   true
  30. removeFromPreviewOnError Boolean   false
  31. deleteUrl String 删除图片时的请求路径 ''
  32. deleteExtraData Object 删除图片时额外传入的参数 {}
  33. overwriteInitial Boolean   true
  34. previewZoomButtonIcons Object   {prev: '<i class="glyphicon glyphicon-triangle-left"></i>',  next: '<i class="glyphicon glyphicon-triangle-right"></i>',  toggleheader: '<i class="glyphicon glyphicon-resize-vertical"></i>',  fullscreen: '<i class="glyphicon glyphicon-fullscreen"></i>',  borderless: '<i class="glyphicon glyphicon-resize-full"></i>',  close: '<i class="glyphicon glyphicon-remove"></i>'},
  35. previewZoomButtonClasses Object   {  prev: 'btn btn-navigate',  next: 'btn btn-navigate',  toggleheader: 'btn btn-default btn-header-toggle',  fullscreen: 'btn btn-default',  borderless: 'btn btn-default',  close: 'btn btn-default'},
  36. preferIconicPreview Boolrean   false
  37. preferIconicZoomPreview Boolrean   false
  38. allowedPreviewTypes undefined   undefined
  39. allowedPreviewMimeTypes Object   null
  40. allowedFileTypes Object 接收的文件后缀,如['jpg', 'gif', 'png'],不填将不限制上传文件后缀类型 null
  41. allowedFileExtensions Object   null
  42. defaultPreviewContent Object   null
  43. customLayoutTags Object   {}
  44. customPreviewTags Object   {}
  45. previewFileIcon String   '<i class="glyphicon glyphicon-file"></i>'
  46. previewFileIconClass String   'file-other-icon'
  47. previewFileIconSettings Object   {}
  48. previewFileExtSettings Object   {}
  49. buttonLabelClass String   'hidden-xs'
  50. browseIcon String   '<i class="glyphicon glyphicon-folder-open"></i> '
  51. browseClass String   'btn btn-primary'
  52. removeIcon String   '<i class="glyphicon glyphicon-trash"></i>'
  53. removeClass String   'btn btn-default'
  54. cancelIcon String   '<i class="glyphicon glyphicon-ban-circle"></i>'
  55. cancelClass String   'btn btn-default'
  56. uploadIcon String   '<i class="glyphicon glyphicon-upload"></i>'
  57. uploadClass String   'btn btn-default'
  58. uploadUrl String 上传文件路径 null
  59. uploadAsync boolean 是否为异步上传 true
  60. uploadExtraData   上传文件时额外传递的参数设置 {}
  61. zoomModalHeight number   480
  62. minImageWidth String 图片的最小宽度 null
  63. minImageHeight String 图片的最小高度 null
  64. maxImageWidth String 图片的最大宽度 null
  65. maxImageHeight String 图片的最大高度 null
  66. resizeImage boolean   false
  67. resizePreference String   'width'
  68. resizeQuality number   0.92
  69. resizeDefaultImageType String   'image/jpeg'
  70. minFileSize number 单位为kb,上传文件的最小大小值 0
  71. maxFileSize number 单位为kb,如果为0表示不限制文件大小 0
  72. resizeDefaultImageType number   25600(25MB)
  73. minFileCount number 表示同时最小上传的文件个数 0
  74. maxFileCount number 表示允许同时上传的最大文件个数 0
  75. validateInitialCount boolean   false
  76. msgValidationErrorClass String   'text-danger'
  77. msgValidationErrorIcon String   '<i class="glyphicon glyphicon-exclamation-sign"></i> '
  78. msgErrorClass String   'file-error-message'
  79. progressThumbClass String   "progress-bar progress-bar-success progress-bar-striped active"
  80. rogressClass String   "progress-bar progress-bar-success progress-bar-striped active"
  81. progressCompleteClass String   "progress-bar progress-bar-success"
  82. progressErrorClass String   "progress-bar progress-bar-danger"
  83. progressUploadThreshold number   99
  84. previewFileType String 预览文件类型,内置['image', 'html', 'text', 'video', 'audio', 'flash', 'object',‘other‘]等格式 'image'
  85. elCaptionContainer String   null
  86. elCaptionText String 设置标题栏提示信息 null
  87. elPreviewContainer String   null
  88. elPreviewImage String   null
  89. elPreviewStatus String   null
  90. elErrorContainer String   null
  91. errorCloseButton String   '<span class="close kv-error-close">×</span>'
  92. slugCallback String   null
  93. dropZoneEnabled boolean 是否显示拖拽区域 true
  94. dropZoneTitleClass String 拖拽区域类属性设置 'file-drop-zone-title'
  95. fileActionSettings Object 设置预览图片的显示样式 {    showRemove: true,    showUpload: false,    showZoom: true,    showDrag: true,    removeIcon: '<i class="glyphicon glyphicon-trash text-danger"></i>',    removeClass: 'btn btn-xs btn-default',    removeTitle: 'Remove file',    uploadIcon: '<i class="glyphicon glyphicon-upload text-info"></i>',    uploadClass: 'btn btn-xs btn-default',    uploadTitle: 'Upload file',    zoomIcon: '<i class="glyphicon glyphicon-zoom-in"></i>',    zoomClass: 'btn btn-xs btn-default',    zoomTitle: 'View Details',    dragIcon: '<i class="glyphicon glyphicon-menu-hamburger"></i>',    dragClass: 'text-info',    dragTitle: 'Move / Rearrange',    dragSettings: {},    indicatorNew: '<i class="glyphicon glyphicon-hand-down text-warning"></i>',    indicatorSuccess: '<i class="glyphicon glyphicon-ok-sign text-success"></i>',    indicatorError: '<i class="glyphicon glyphicon-exclamation-sign text-danger"></i>',    indicatorLoading: '<i class="glyphicon glyphicon-hand-up text-muted"></i>',    indicatorNewTitle: 'Not uploaded yet',    indicatorSuccessTitle: 'Uploaded',    indicatorErrorTitle: 'Upload Error',    indicatorLoadingTitle: 'Uploading ...'}
  96. otherActionButtons String   ''
  97. textEncoding String 编码设置 'UTF-8'
  98. ajaxSettings Object   {}
  99. ajaxDeleteSettings Object   {}
  100. showAjaxErrorDetails boolean   true

3.

  1. 属性名 默认值 中文
  2. fileSingle file 文件
  3. filePlural files 个文件
  4. browseLabel Browse &hellip 选择
  5. removeLabel Remove 移除
  6. removeTitle Clear selected files 清除选中文件
  7. cancelLabel Cancel 取消
  8. cancelTitle Abort ongoing upload 取消进行中的上传
  9. uploadLabel Upload 上传
  10. uploadTitle Upload selected files 上传选中文件
  11. msgNo No 没有
  12. msgNoFilesSelected No files selected “”
  13. msgCancelled Cancelled 取消
  14. msgZoomModalHeading Detailed Preview 详细预览
  15. msgSizeTooSmall File "{name}" (<b>{size} KB</b>) is too small and must be larger than <b>{minSize} KB</b>. File "{name}" (<b>{size} KB</b>) is too small and must be larger than <b>{minSize} KB</b>.
  16. msgSizeTooLarge File "{name}" (<b>{size} KB</b>) exceeds maximum allowed upload size of <b>{maxSize} KB</b>. 文件 "{name}" (<b>{size} KB</b>) 超过了允许大小 <b>{maxSize} KB</b>.
  17. msgFilesTooLess You must select at least <b>{n}</b> {files} to upload. 你必须选择最少 <b>{n}</b> {files} 来上传.
  18. msgFilesTooMany Number of files selected for upload <b>({n})</b> exceeds maximum allowed limit of <b>{m}</b>. 选择的上传文件个数 <b>({n})</b> 超出最大文件的限制个数 <b>{m}</b>.
  19. msgFileNotFound File "{name}" not found! 文件 "{name}" 未找到!
  20. msgFileSecured Security restrictions prevent reading the file "{name}". 安全限制,为了防止读取文件 "{name}".
  21. msgFileNotReadable File "{name}" is not readable. 文件 "{name}" 不可读.
  22. msgFilePreviewAborted File preview aborted for "{name}". 取消 "{name}" 的预览.
  23. msgFilePreviewError An error occurred while reading the file "{name}". 读取 "{name}" 时出现了一个错误.
  24. msgInvalidFileName Invalid or unsupported characters in file name "{name}". Invalid or unsupported characters in file name "{name}".
  25. msgInvalidFileType Invalid type for file "{name}". Only "{types}" files are supported. 不正确的类型 "{name}". 只支持 "{types}" 类型的文件.
  26. msgInvalidFileExtension Invalid extension for file "{name}". Only "{extensions}" files are supported. 不正确的文件扩展名 "{name}". 只支持 "{extensions}" 的文件扩展名.
  27. msgFileTypes {            'image': 'image',            'html': 'HTML',            'text': 'text',            'video': 'video',            'audio': 'audio',            'flash': 'flash',            'pdf': 'PDF',            'object': 'object'        }, {            'image': 'image',            'html': 'HTML',            'text': 'text',            'video': 'video',            'audio': 'audio',            'flash': 'flash',            'pdf': 'PDF',            'object': 'object'        },
  28. msgUploadAborted The file upload was aborted 该文件上传被中止
  29. msgUploadThreshold Processing... Processing...
  30. msgUploadBegin Initializing... Initializing...
  31. msgUploadEnd Done Done
  32. msgUploadEmpty No valid data available for upload. No valid data available for upload.
  33. msgValidationError Validation Error 验证错误
  34. msgLoading Loading file {index} of {files} 加载第 {index} 文件 {files}
  35. msgProgress Loading file {index} of {files} - {name} - {percent}% completed. 加载第 {index} 文件 {files} - {name} - {percent}% 完成.
  36. msgSelected {n} {files} selected {n} {files} 选中
  37. msgFoldersNotAllowed Drag & drop files only! {n} folder(s) dropped were skipped. 只支持拖拽文件! 跳过 {n} 拖拽的文件夹.
  38. msgImageWidthSmall Width of image file "{name}" must be at least {size} px. 宽度的图像文件的"{name}"的必须是至少{size}像素.
  39. msgImageHeightSmall Height of image file "{name}" must be at least {size} px. 图像文件的"{name}"的高度必须至少为{size}像素.
  40. msgImageWidthLarge Width of image file "{name}" cannot exceed {size} px. 宽度的图像文件"{name}"不能超过{size}像素.
  41. msgImageHeightLarge Height of image file "{name}" cannot exceed {size} px. 图像文件"{name}"的高度不能超过{size}像素.
  42. msgImageResizeError Could not get the image dimensions to resize. 无法获取的图像尺寸调整。
  43. msgImageResizeException Error while resizing the image.<pre>{errors}</pre> 错误而调整图像大小。<pre>{errors}</pre>
  44. msgAjaxError Something went wrong with the {operation} operation. Please try again later! Something went wrong with the {operation} operation. Please try again later!
  45. msgAjaxProgressError {operation} failed {operation} failed
  46. ajaxOperations {            deleteThumb: 'file delete',            uploadThumb: 'file upload',            uploadBatch: 'batch file upload',            uploadExtra: 'form data upload'        }, {            deleteThumb: 'file delete',            uploadThumb: 'file upload',            uploadBatch: 'batch file upload',            uploadExtra: 'form data upload'        },
  47. dropZoneTitle Drag & drop files here 拖拽文件到这里 …<br>支持多文件同时上传
  48. dropZoneClickTitle <br>(or click to select {files}) <br>(或点击{files}按钮选择文件)
  49. previewZoomButtonTitles {            prev: 'View previous file',            next: 'View next file',            toggleheader: 'Toggle header',            fullscreen: 'Toggle full screen',            borderless: 'Toggle borderless mode',            close: 'Close detailed preview'        } {            prev: '预览上一个文件',            next: '预览下一个文件',            toggleheader: '缩放',            fullscreen: '全屏',            borderless: '无边界模式',            close: '关闭当前预览'        }
  50. fileActionSettings   {     removeTitle: '删除文件',            uploadTitle: '上传文件',            zoomTitle: '查看详情',            dragTitle: '移动 / 重置',            indicatorNewTitle: '没有上传',            indicatorSuccessTitle: '上传',            indicatorErrorTitle: '上传错误',            indicatorLoadingTitle: '上传 ...'        },

4.

  1. 方法名 参数 描述
  2. fileerror   异步上传错误结果处理$('#uploadfile').on('fileerror', function(event, data, msg) {   });
  3. fileuploaded   异步上传成功结果处理$("#uploadfile").on("fileuploaded", function (event, data, previewId, index) {  })
  4. filebatchuploaderror   同步上传错误结果处理$('#uploadfile').on('filebatchuploaderror', function(event, data, msg) {     });
  5. filebatchuploadsuccess   同步上传成功结果处理$('#uploadfile').on('filepreupload', function(event, data, previewId, index) {       });
  6. filebatchselected   选择文件后处理事件$("#fileinput").on("filebatchselected", function(event, files) {});
  7. upload   文件上传方法$("#fileinput").fileinput("upload");
  8. fileuploaded   上传成功后处理方法$("#fileinput").on("fileuploaded", function(event, data, previewId, index) {});
  9. filereset    
  10. fileclear   点击浏览框右上角X 清空文件前响应事件$("#fileinput").on("fileclear",function(event, data, msg){});
  11. filecleared   点击浏览框右上角X 清空文件后响应事件$("#fileinput").on("filecleared",function(event, data, msg){});
  12. fileimageuploaded   在预览框中图片已经完全加载完毕后回调的事件

5.项目使用

  1. <div class="control-group">
  2. <label class="control-label">上传期刊: <span class="help-inline"><font color="red">*</font> </span></label>
  3. <div class="controls">
  4. <form:hidden id ="attachment" path="attachment"/>
  5. <input id="inputFile" type="file" class="file-loading required" data-preview-file-type="text" name="file" value="${periodicalResource.attachment}" class="input-xlarge" >
  6. <font color="red">*</font>
  7. <span class="help-inline"><font>请上传pdf格式文件</font></span>
  8. </div>
  9. </div>
  1. //初始化fileinput控件 tushu
  2. $("#inputFile").fileinput({
  3. showUpload : true,
  4. showRemove : false,
  5. uploadUrl:"${ctx}/upload/one/8",
  6. language : 'zh',
  7. allowedPreviewTypes : [ 'pdf' ],
  8. allowedFileTypes : ['pdf'],
  9. autoReplace:true,
  10. maxFileCount:1,
  11. browseClass: "btn btn-primary", //按钮样式
  12. dropZoneEnabled: true,//shidou显示拖拽
  13. initialPreviewAsData: true,
  14. initialPreviewFileType: 'pdf',
  15. <c:if test="${periodicalResource.attachment!=null&&periodicalResource.attachment!=''}">initialPreview:["${periodicalResource.attachment}"]</c:if>
  16. }).on("fileuploaded", function (event, data) {
  17. $("#attachment").val(data.response.attachment);
  18. });

有些东西还得问人 请教  自己的知识有限

欢迎各位道友吐槽

Bootstrap FileInput 上传 中文 API 整理的更多相关文章

  1. bootstrap fileinput上传文件

    参考博客:https://blog.csdn.net/linhaiyun_ytdx/article/details/76215974  https://www.cnblogs.com/parker-y ...

  2. bootstrap fileinput 上传文件

    最近用到文件上传功能, 说实话:以前遇到过一次,COPY了别人的代码 结束! 这次又要用,可是看到别人很酷的文件上传功能,心痒了! 好吧.简单的办法,找控件: bootstrap fileinput ...

  3. .net core版 文件上传/ 支持批量上传,拖拽以及预览,bootstrap fileinput上传文件

    asp.net mvc请移步 mvc文件上传支持批量上传,拖拽以及预览,文件内容校验 本篇内容主要解决.net core中文件上传的问题  开发环境:ubuntu+vscode 1.导入所需要的包:n ...

  4. 关于Bootstrap fileinput 上传新文件,移除时触发服务器同步删除的配置

    在Bootstrap fileinput中移除预览文件时可以通过配置initialPreviewConfig: [ { url:'deletefile',key:fileid } ] 来同步删除服务器 ...

  5. bootstrap fileinput上传返回400,404,500 等错误替换

    $(".uploadfile").on('filebatchuploaderror', function(event, data, msg) { $(".file-err ...

  6. 【转】Bootstrap FileInput中文API整理

    Bootstrap FileInput中文API整理 这段时间做项目用到bootstrap fileinput插件上传文件,在用的过程中,网上能查到的api都不是很全,所以想着整理一份比较详细的文档, ...

  7. JS组件系列——Bootstrap文件上传组件:bootstrap fileinput

    前言:之前的三篇介绍了下bootstrap table的一些常见用法,发现博主对这种扁平化的风格有点着迷了.前两天做一个excel导入的功能,前端使用原始的input type='file'这种标签, ...

  8. 基于bootstrap的上传插件fileinput实现ajax异步上传功能(支持多文件上传预览拖拽)

    首先需要导入一些js和css文件 ? 1 2 3 4 5 6 <link href="__PUBLIC__/CSS/bootstrap.css" rel="exte ...

  9. bootstrap文件上传fileupload插件

    Bootstrap FileInput中文API整理:https://blog.csdn.net/u012526194/article/details/69937741 SpringMVC + boo ...

随机推荐

  1. JavaScript组合模式---引入

    首先:使用一个例子来引入组合模式,需求为(1)有一个学校有2个班(一班,二班)(2)每个班级分2个小组(一班一组,一班二组,二班一组,二班二组)(3)学校计算机教室有限,每一个小组分着来上课 然后:根 ...

  2. form(去掉关闭按钮,禁止调整大小)

    禁止Form窗口调整大小方法:FormBorderStyle 设为FixedSingle: 不能使用最大化窗口: MaximuzeBox 设为False: 不能使用最小化窗口:   MinimizeB ...

  3. DAY19-上传头像并预览

    一个简单的注册页面: <!DOCTYPE html> <html lang="en"> <head> <meta charset=&quo ...

  4. java中一些常用的英语

     abstract (关键字  ) 抽象  ['.bstr.kt]  access vt.访问,存取  ['.kses]'(n.入口,使用权)  algorithm n.算法  ['.lg.rie ...

  5. SSM项目连接远程Linux服务器的mysql 启动tomcat卡在了 Initializing Spring root WebApplicationContext

    网上查了原因, linux下mysql访问速度缓慢并且ssh连接缓慢的原因 解决办法: 1.linux ssh连接慢 最近发现ssh连接的时候却很慢,ping的速度非常好,让人误以为是ssh连接不上. ...

  6. 百度Apollo解析——1.总介绍

    1. 概括 Apollo源码主要是c++实现的,也有少量python,主要程序在apollo/modules目录中,共18个包,功能包17个: 其中每个模块的作用如下: apollo/modules/ ...

  7. ROS探索总结(六)——使用smartcar进行仿真

    转自:https://www.ncnynl.com/archives/201609/843.html 总结: 一.机器人描述文件三个: 机器人主体body文件: gazebo属性文件: 主文件 sma ...

  8. 开发同事 Linux 实用基本操作

    Linux 有复杂的体系,有很多的命令,开发同事日常开发时,不像运维同事需要熟练使用很多命令. 下面记录下我在工作中,常用的基本命令: 一 日志查看 对于开发同事来说,日常工作中,Linux 中最常用 ...

  9. PCL—点云分割(基于凹凸性) 低层次点云处理

    博客转载自:http://www.cnblogs.com/ironstark/p/5027269.html 1.图像分割的两条思路 场景分割时机器视觉中的重要任务,尤其对家庭机器人而言,优秀的场景分割 ...

  10. PDF的一些工具

    PdfStreamDumper Pdftk 这里有一个链接,列出了很多pdf免费工具 https://en.wikipedia.org/wiki/Category:Free_PDF_software ...