//上传文件
function fileInputUpload(id,url,successfn){
$("#"+id).fileinput({
language: 'zh', //设置语言
overwriteInitial: true,
maxFileSize: 20480,
allowedFileExtensions: ['doc', 'docx', 'pdf', 'zip', 'rar', 'xls', 'xlsx','jpg','jpeg','png'],
uploadAsync: true,
showPreview: false,
showRemove: true,
uploadUrl: url,
ajaxSettings: {
async: false,
dataType: 'json',
success: function(result) {
successfn(result);
}
}
});
}
//上传文件调用
fileInputUpload("uploadFile","${ctx}/upload.do",function(result){
var path = '',name='',html = '';
$(result).each(function(index, item) {
path += item.relativePath + ';'
name += item.fileName+';';
html += '<p><a href="' + item.relativePath + '" class="colorActive" target="_blank">' + item.fileName + '</a></p>'
});
$('#extFilePath').val(path.substr(0, path.length - 1));
$('#extFileName').val(name.substr(0, name.length - 1));
$('.js_file_show').html(html);
});
jquery ajax fileinput封装上传插件回调方法
猜你喜欢
转载自blog.csdn.net/fzy629442466/article/details/84786265
周排行