Bootstrap FileInput中文API文档
2021-02-10 09:23
Bootstrap FileInput中文API整理
这段时间做项目用到bootstrap fileinput插件上传文件,在用的过程中,网上能查到的api都不是很全,所以想着整理一份比较详细的文档,方便自己今后使用,也希望能给大家带来帮助,如有错误,希望大家积极指正。
一、 引入文件
二、 初始化设置:
$("#uploadfile").fileinput({
language: ‘zh‘, //设置语言
uploadUrl:"http://127.0.0.1/testDemo/fileupload/upload.do", //上传的地址
allowedFileExtensions: [‘jpg‘, ‘gif‘, ‘png‘],//接收的文件后缀
//uploadExtraData:{"id": 1, "fileName":‘123.mp3‘},
uploadAsync: true, //默认异步上传
showUpload:true, //是否显示上传按钮
showRemove :true, //显示移除按钮
showPreview :true, //是否显示预览
showCaption:false,//是否显示标题
browseClass:"btn btn-primary", //按钮样式
dropZoneEnabled: false,//是否显示拖拽区域
//minImageWidth: 50, //图片的最小宽度
//minImageHeight: 50,//图片的最小高度
//maxImageWidth: 1000,//图片的最大宽度
//maxImageHeight: 1000,//图片的最大高度
//maxFileSize:0,//单位为kb,如果为0表示不限制文件大小
//minFileCount: 0,
maxFileCount:10, //表示允许同时上传的最大文件个数
enctype:‘multipart/form-data‘,
validateInitialCount:true,
previewFileIcon: "
msgFilesTooMany: "选择上传的文件数量({n}) 超过允许的最大数值{m}!",
}).on("fileuploaded", function (event, data, previewId, index){
});
三、 Options 说明:
属性名 |
属性类型 |
描述说明 |
默认值 |
language |
String |
多语言设置,使用时需提前引入\locales文件夹下对应的语言文件,中文zh,引入语言文件必须放在fileinput.js之后 |
‘en‘ |
showCaption |
Boolean |
是否显示被选文件的简介 |
true |
showBrowse |
Boolean |
是否显示浏览按钮 |
true |
showPreview |
Boolean |
是否显示预览区域 |
true |
showRemove |
Boolean |
是否显示移除按钮 |
true, |
showUpload |
Boolean |
是否显示上传按钮 |
true, |
showCancel |
Boolean |
是否显示取消按钮 |
true, |
showClose: |
Boolean |
是否显示关闭按钮 |
true |
showUploadedThumbs |
Boolean |
|
true |
browseOnZoneClick |
Boolean |
|
false |
autoReplace |
Boolean |
是否自动替换当前图片,设置为true时,再次选择文件, 会将当前的文件替换掉。 |
false |
generateFileId |
Object |
|
null |
previewClass |
String |
添加预览按钮的类属性 |
‘’ |
captionClass |
String |
|
‘’ |
frameClass |
String |
|
‘krajee-default‘ |
mainClass |
String |
|
‘file-caption-main‘ |
mainTemplate |
Object |
|
null |
purifyHtml |
Boolean |
|
true |
fileSizeGetter |
Object |
|
null |
initialCaption |
String |
|
‘‘ |
initialPreview |
Array/Object |
|
[] |
initialPreviewDelimiter |
String |
|
‘*$$*‘ |
initialPreviewAsData |
Boolean |
|
false |
initialPreviewFileType |
String |
|
‘image‘ |
initialPreviewConfig |
Array/Object |
|
[] |
initialPreviewThumbTags |
Array/Object |
|
[] |
previewThumbTags |
Object |
|
{} |
initialPreviewShowDelete |
Boolean |
|
true |
removeFromPreviewOnError |
Boolean |
|
false |
deleteUrl |
String |
删除图片时的请求路径 |
‘‘ |
deleteExtraData |
Object |
删除图片时额外传入的参数 |
{} |
overwriteInitial |
Boolean |
|
true |
previewZoomButtonIcons |
Object |
|
{ prev: ‘‘, next: ‘‘, toggleheader: ‘‘, fullscreen: ‘‘, borderless: ‘‘, close: ‘‘ }, |
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‘ }, |
preferIconicPreview |
Boolrean |
|
false |
preferIconicZoomPreview |
Boolrean |
|
false |
allowedPreviewTypes |
undefined |
|
undefined |
allowedPreviewMimeTypes |
Object |
|
null |
allowedFileTypes |
Object |
接收的文件后缀,如[‘jpg‘, ‘gif‘, ‘png‘],不填将不限制上传文件后缀类型 |
null |
allowedFileExtensions |
Object |
|
null |
defaultPreviewContent |
Object |
|
null |
customLayoutTags |
Object |
|
{} |
customPreviewTags |
Object |
|
{} |
previewFileIcon |
String |
|
‘‘ |
previewFileIconClass |
String |
|
‘file-other-icon‘ |
previewFileIconSettings |
Object |
|
{} |
previewFileExtSettings |
Object |
|
{} |
buttonLabelClass |
String |
|
‘hidden-xs‘ |
browseIcon |
String |
|
‘ ‘ |
browseClass |
String |
|
‘btn btn-primary‘ |
removeIcon |
String |
|
‘‘ |
removeClass |
String |
|
‘btn btn-default‘ |
cancelIcon |
String |
|
‘‘ |
cancelClass |
String |
|
‘btn btn-default‘ |
uploadIcon |
String |
|
‘‘ |
uploadClass |
String |
|
‘btn btn-default‘ |
uploadUrl |
String |
上传文件路径 |
null |
uploadAsync |
boolean |
是否为异步上传 |
true |
uploadExtraData |
|
上传文件时额外传递的参数设置 |
{} |
zoomModalHeight |
number |
|
480 |
minImageWidth |
String |
图片的最小宽度 |
null |
minImageHeight |
String |
图片的最小高度 |
null |
maxImageWidth |
String |
图片的最大宽度 |
null |
maxImageHeight |
String |
图片的最大高度 |
null |
resizeImage |
boolean |
|
false |
resizePreference |
String |
|
‘width‘ |
resizeQuality |
number |
|
0.92 |
resizeDefaultImageType |
String |
|
‘image/jpeg‘ |
minFileSize |
number |
单位为kb,上传文件的最小大小值 |
0 |
maxFileSize |
number |
单位为kb,如果为0表示不限制文件大小 |
0 |
resizeDefaultImageType |
number |
|
25600(25MB) |
minFileCount |
number |
表示同时最小上传的文件个数 |
0 |
maxFileCount |
number |
表示允许同时上传的最大文件个数 |
0 |
validateInitialCount |
boolean |
|
false |
msgValidationErrorClass |
String |
|
‘text-danger‘ |
msgValidationErrorIcon |
String |
|
‘ ‘ |
msgErrorClass |
String |
|
‘file-error-message‘ |
progressThumbClass |
String |
|
"progress-bar progress-bar-success progress-bar-striped active" |
rogressClass |
String |
|
"progress-bar progress-bar-success progress-bar-striped active" |
progressCompleteClass |
String |
|
"progress-bar progress-bar-success" |
progressErrorClass |
String |
|
"progress-bar progress-bar-danger" |
progressUploadThreshold |
number |
|
99 |
previewFileType |
String |
预览文件类型,内置[‘image‘, ‘html‘, ‘text‘, ‘video‘, ‘audio‘, ‘flash‘, ‘object‘,‘other‘]等格式 |
‘image‘ |
elCaptionContainer |
String |
|
null |
elCaptionText |
String |
设置标题栏提示信息 |
null |
elPreviewContainer |
String |
|
null |
elPreviewImage |
String |
|
null |
elPreviewStatus |
String |
|
null |
elErrorContainer |
String |
|
null |
errorCloseButton |
String |
|
‘ב |
slugCallback |
String |
|
null |
dropZoneEnabled |
boolean |
是否显示拖拽区域 |
true |
dropZoneTitleClass |
String |
拖拽区域类属性设置 |
‘file-drop-zone-title‘ |
fileActionSettings |
Object |
设置预览图片的显示样式 |
{ showRemove: true, showUpload: false, showZoom: true, showDrag: true, removeIcon: ‘‘, removeClass: ‘btn btn-xs btn-default‘, removeTitle: ‘Remove file‘, uploadIcon: ‘‘, uploadClass: ‘btn btn-xs btn-default‘, uploadTitle: ‘Upload file‘, zoomIcon: ‘‘, zoomClass: ‘btn btn-xs btn-default‘, zoomTitle: ‘View Details‘, dragIcon: ‘‘, dragClass: ‘text-info‘, dragTitle: ‘Move / Rearrange‘, dragSettings: {}, indicatorNew: ‘‘, indicatorSuccess: ‘‘, indicatorError: ‘‘, indicatorLoading: ‘‘, indicatorNewTitle: ‘Not uploaded yet‘, indicatorSuccessTitle: ‘Uploaded‘, indicatorErrorTitle: ‘Upload Error‘, indicatorLoadingTitle: ‘Uploading ...‘ } |
otherActionButtons |
String |
|
‘‘ |
textEncoding |
String |
编码设置 |
‘UTF-8‘ |
ajaxSettings |
Object |
|
{} |
ajaxDeleteSettings |
Object |
|
{} |
showAjaxErrorDetails |
boolean |
|
true |
四、 提示说明设置:
属性名 |
默认值 |
中文 |
fileSingle |
file |
文件 |
filePlural |
files |
个文件 |
browseLabel |
Browse &hellip |
选择 … |
removeLabel |
Remove |
移除 |
removeTitle |
Clear selected files |
清除选中文件 |
cancelLabel |
Cancel |
取消 |
cancelTitle |
Abort ongoing upload |
取消进行中的上传 |
uploadLabel |
Upload |
上传 |
uploadTitle |
Upload selected files |
上传选中文件 |
msgNo |
No |
没有 |
msgNoFilesSelected |
No files selected |
“” |
msgCancelled |
Cancelled |
取消 |
msgZoomModalHeading |
Detailed Preview |
详细预览 |
msgSizeTooSmall |
File "{name}" ({size} KB) is too small and must be larger than {minSize} KB. |
File "{name}" ({size} KB) is too small and must be larger than {minSize} KB. |
msgSizeTooLarge |
File "{name}" ({size} KB) exceeds maximum allowed upload size of {maxSize} KB. |
文件 "{name}" ({size} KB) 超过了允许大小 {maxSize} KB. |
msgFilesTooLess |
You must select at least {n} {files} to upload. |
你必须选择最少 {n} {files} 来上传. |
msgFilesTooMany |
Number of files selected for upload ({n}) exceeds maximum allowed limit of {m}. |
选择的上传文件个数 ({n}) 超出最大文件的限制个数 {m}. |
msgFileNotFound |
File "{name}" not found! |
文件 "{name}" 未找到! |
msgFileSecured |
Security restrictions prevent reading the file "{name}". |
安全限制,为了防止读取文件 "{name}". |
msgFileNotReadable |
File "{name}" is not readable. |
文件 "{name}" 不可读. |
msgFilePreviewAborted |
File preview aborted for "{name}". |
取消 "{name}" 的预览. |
msgFilePreviewError |
An error occurred while reading the file "{name}". |
读取 "{name}" 时出现了一个错误. |
msgInvalidFileName |
Invalid or unsupported characters in file name "{name}". |
Invalid or unsupported characters in file name "{name}". |
msgInvalidFileType |
Invalid type for file "{name}". Only "{types}" files are supported. |
不正确的类型 "{name}". 只支持 "{types}" 类型的文件. |
msgInvalidFileExtension |
Invalid extension for file "{name}". Only "{extensions}" files are supported. |
不正确的文件扩展名 "{name}". 只支持 "{extensions}" 的文件扩展名. |
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‘ }, |
msgUploadAborted |
The file upload was aborted |
该文件上传被中止 |
msgUploadThreshold |
Processing... |
Processing... |
msgUploadBegin |
Initializing... |
Initializing... |
msgUploadEnd |
Done |
Done |
msgUploadEmpty |
No valid data available for upload. |
No valid data available for upload. |
msgValidationError |
Validation Error |
验证错误 &l |
文章标题:Bootstrap FileInput中文API文档
文章链接:http://soscw.com/index.php/essay/53513.html