js代码:
<link href="${ctxStatic}/ewider/js/iejs/uploadify.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${ctxStatic}/ewider/js/iejs/jquery.uploadify.min.js"></script>
$(document).ready(function(){
$('#sendToImg').uploadify({
swf: ctxStatic+'/ewider/js/iejs/uploadify.swf',
uploader : window.parent.getUploadServer(),
auto: true,
checkExisting:false,
fileSizeLimit:"20MB",
fileObjName:"file",
width: "30",
height: "30",
buttonClass:"hide",
buttonText: " ",
fileTypeExts:"*.gif;*.jpg;*.jpeg;*.bmp;*.png",
onUploadSuccess :function(file, data, response) {
var result = JSON.parse(data);
sendImage(result.attachmentId,result.fileName);
},
onUploadError : function(file, errorCode, errorMsg, errorString) {
alert("文件上传不了");
}
});
$('#sendFile').uploadify({
swf: ctxStatic+'/ewider/js/iejs/uploadify.swf',
uploader : window.parent.getUploadServer(),
auto: true,
checkExisting:false,
fileSizeLimit:"20MB",
fileObjName:"file",
width: "30",
height: "30",
buttonClass:"hide",
buttonText: " ",
onUploadSuccess :function(file, data, response) {
var result = JSON.parse(data);
sendFile(result.attachmentId,result.fileName);
},
onUploadError : function(file, errorCode, errorMsg, errorString) {
alert("文件上传不了");
}
});
});
<input name="file" id="sendToImg" type="sendToImg"/>
<input id="sendFile" name="sendFile" type="file" />
搞定:如果需要修改按钮的样式的话:用buttonClass属性或者直接更改按钮图片