1. 前端以ExtJs的形式显示。
{xtype: ' form ', id: ' mainPic ' , hidden: false, border: false , layout : ' hbox ', items: [
{xtype: ' label ' , text: ' 主推图片:' ,style: ' color: #666666 '},
{xtype: ' label ' , width: 50 },
{xtype: ' hidden ',name :' path ', value:''},
{
xtype: 'fileuploadfield',
width: 495,
emptyText: '建议尺寸:970*360 像素',
buttonCfg: {
text: '浏览',
iconCls: 'icon-upload'
},
regex: img_reg,
name: 'image',
regexText: '请上传图片格式的文件',
listeners: {
'change': function () {
var uploadForm = this.up('form').getForm();
var form = this.up('form');
if (uploadForm.isValid()) {
uploadForm.submit({
url: ctx+'/photo/uploadPhoto',
method: 'post',
params:{
appVersion:1
},
failure: function (form, action) {
var status = Ext.decode(action.response.responseText).status;
var picId = Ext.decode(action.response.responseText).data.photoId;
if(status=="success"){
Ext.getCmp('browseMainImage').setWidth(200)
Ext.getCmp('browseMainImage').setHeight(155)
Ext.getCmp('browseMainImage').getEl().dom.src = ctx+"/photo/getPhoto?photoId=" + picId+"&width=200"+"&height=150";
Ext.getCmp('browseMainImage').photoId= picId;
Ext.getCmp('photoId').setValue(picId);
Ext.Msg.alert('确认', '上传成功');
}else{
Ext.Msg.alert('警告', '上传失败');
}
}
});
}else{
Ext.Msg.alert("","");
}
}
}
}
]},
{xtype: 'form', width:600,border: false, layout: '', items: [
{
xtype: ' image ',
margin:' 5 0 0 100 ',
id: ' browseMainImage ',
photoId : null,