jsp页面信息如下,整个页面信息
pageEncoding="utf-8" import="java.io.*"%>
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
content="initial-scale=1.0,user-scalable=no, minimum-scale=1,maximum-scale=1,width=device-width"
name="viewport">
上传图片id="fileupload" type="file" name="file" multiple>
/*global window, $ */
$(function() {
'use strict';
var url = window.location.hostname == 'blueimp.github.io' ? '//jquery-file-upload.appspot.com/'
: 'user.action?methods=editimg', uploadButton = $('')
.addClass('btn btn-primary').prop('disabled', true).text(
'Processing...').on('click', function() {
var $this = $(this), data = $this.data();
$this.off('click').text('正在上传').on('click', function() {
$this.remove();
data.abort();
});
data.submit().always(function() {
$this.remove();
});
});
$('#fileupload').fileupload({
url : url,
dataType : 'json',
autoUpload : false,
acceptFileTypes : /(\.|\/)(gif|jpe?g|png)$/i,
maxFileSize : 5000000, // 5 MB
disableImageResize : /Android(?!.*Chrome)|Opera/
.test(window.navigator.userAgent),
previewMaxWidth : 100,
previewMaxHeight : 100,
previewCrop : true
}).on(
'fileuploadadd',
function(e, data) {
data.context = $('
$.each(data.files, function(index, file) {
var node = $('
$('').text(file.name));
if (!index) {
node.append('
').append(
uploadButton.clone(true).data(data));
}
node.appendTo(data.context);
});
}).on('fileuploadprocessalways',function(e, data) {
var index = data.index, file = data.files[index], node = $(data.context.children()[index]);
if (file.preview) {
node.prepend('
').prepend(file.preview);
}
if (file.error) {
node.append('
').append(
$('').text(
file.error));
}
if (index + 1 === data.files.length) {
data.context.find('button').text('上传').prop(
'disabled', !!data.files.error);
}
}).on('fileuploadprogressall', function(e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .progress-bar').css('width', progress + '%');
}).on('fileuploaddone',function(e, data) {
var result = data.result.code;
if(result=='1'){
globe.lvToast(false, "图像上传成功!", LT_LOADING_CLOSE);
setTimeout(function() {
//window.location.href = "index.action";
}, 2000);
}else{
globe.lvToast(false, data.msg, LT_LOADING_CLOSE);
}
}).on('fileuploadfail',
function(e, data) {
globe.lvToast(false, '头像上传失败', LT_LOADING_CLOSE);
}).prop('disabled', !$.support.fileInput).parent().addClass($.support.fileInput ? undefined : 'disabled');
});