Ext 图片上传及预览,兼容多中浏览器
来源:互联网 发布:linux查看log文件 编辑:程序博客网 时间:2024/05/16 00:32
1、说明x-form-el-browseImage可以通过开发人员工具在html代码中查得
//创建表单面板
var buildFormPanel = function(){
formPanel = new Ext.form.FormPanel({
frame:true,
labelAlign:'right', //标签位置
labelWidth:80,
bodyStyle:'margin: 5 0 0 0',
width:500,
onSubmit: Ext.emptyFn,
method:'POST',
hight:250,
border:false,
buttonAlign : 'center', //按钮位置
enctype: 'multipart/form-data',
fileUpload : true,
layout:'form',
items:[
new Ext.form.FieldSet({
title: "基本信息",
width: 470,
height: 180,
layout:'column',
items:[
{
columnWidth:.5,
autoHeight:true,
layout:'form',
defaultType:'textfield',
style:'margin-top:5px',
itemsCls:'required',
anchor:'90%',
border:false,
items:
[
{fieldLabel : "id", name:"id",hidden:true},
{fieldLabel : "名称", name:"name",allowBlank:false},
add_type,
add_subject,
search_effect,
{fieldLabel : "生长环境", name:"growthEnvironment"},
dishStatus
]
},{
columnWidth:.5,
autoHeight:true,
layout:'form',
defaultType:'textfield',
style:'margin-top:5px',
itemsCls:'required',
anchor:'90%',
border:false,
items:
[
{
id : 'file-idx',
name : 'file',
inputType : "file",
xtype : 'textfield',
blankText:'上传图片不能为空',
anchor : '100%',
listeners:{
'render':function(e){
Ext.get('file-idx').on('change',function(field, newValue, oldValue){
var url = 'file://'+ Ext.get('file-idx').dom.value;
var img_reg = /\.([jJ][pP][gG]){1}$|\.([jJ][pP][eE][gG]){1}$|\.([gG][iI][fF]){1}$|\.([pP][nN][gG]){1}$|\.([bB][mM][pP]){1}$/;
if (img_reg.test(url)) {
if (Ext.isIE) {
document.getElementById("file-idx").select();
var path = document.selection.createRange().text;
document.getElementById("x-form-el-browseImage").style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',sizingMethod='scale',src=\"" + path + "\")";//使用滤镜效果
}// 支持FF
else
{
Ext.get('imageBrowse').dom.src = URL.createObjectURL(Ext.get('file-idx').dom.files[0]);
}
}
else
{
Ext.MessageBox.alert("提示","上传图片格式不正确");
}
});
}
}
},
{
xtype : 'box',
id : 'browseImage',
complete:'off',
fieldLabel : "预览",
autoEl : {
width : 140,
height:100,
border:true,
tag : 'img',
style : 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale);',
complete : 'off',
id : 'imageBrowse'
}
}
]
}
]
}),
new Ext.form.FieldSet({
title: "简介",
width: 470,
height: 200,
layout:'column',
items:[
new Ext.form.TextArea({
height:180,
width:450,
maxLengthText:135,
name:'brief',
autoScroll:true
})
]
})
],
buttons:[
{
id:"sub",
text:'提交',
handler:function(){
if(formPanel.form.isValid()){
if(formPanel.isAdd) //添加
{
if(Ext.getCmp('file-idx').getValue()=='' || Ext.getCmp('file-idx').getValue()==null || Ext.getCmp('file-idx').getValue().length==0)
{
Ext.MessageBox.alert("提示","图片信息部能为空!");
}
else
{
formPanel.form.submit({
clienValidation:true,
waitMsg:'正在上传信息,请稍等...',
waitTitle:'提示',
url:'<%=path %>/greenLease/addGreenLeaseInfo.do',
method:'POST',
success:function(form,action){
alert("提交成功");
store.reload({params:{start:0,limit:50}});
win.hide();
},
failure:function(form,action){
Ext.MessageBox.show({title: '失败',msg: '上传失败!',buttons: Ext.MessageBox.OK,icon: Ext.MessageBox.ERROR});
}
});
}
}
else //修改
{
formPanel.form.submit({
clienValidation:true,
waitMsg:'正在上传信息,请稍等...',
waitTitle:'提示',
url:'<%=path %>/greenLease/editGreenLeaseInfo.do',
method:'POST',
success:function(form,action){
alert("提交成功");
formPanel.form.getEl().dom.reset();
store.reload({params:{start:0,limit:50}});
win.hide();
},
failure:function(form,action){
Ext.MessageBox.show({title: '失败',msg: '上传失败!',buttons: Ext.MessageBox.OK,icon: Ext.MessageBox.ERROR});
}
});
}
}
}
},
{
id:"cancel",
text:'取消',
handler:function(){
formPanel.form.reset();
win.hide();
}
}
]
});
};
- Ext 图片上传及预览,兼容多中浏览器
- 图片本地预览并上传多个浏览器兼容
- 上传图片预览一定要兼容所有浏览器
- 上传图片动态预览(兼容主流浏览器)
- 兼容各个浏览器的图片上传预览
- html5 图片上传,支持图片预览、压缩、及进度显示,兼容IE6+及标准浏览器
- javascript上传图片前预览图片兼容大多数浏览器
- 图片上传预览,兼容IE6、IE7、IE8和firefox浏览器
- 兼容浏览器图片上传本地预览功能js脚本
- jquery实现兼容浏览器的图片上传本地预览功能
- jquery实现兼容浏览器的图片上传本地预览功能
- 真正实现兼容IE6以上主流浏览器-上传图片预览
- 兼容微信浏览器的本地图片上传预览
- JavaScript 图片的上传前预览(兼容所有浏览器)
- html5 + jq 实现图片上传预览,兼容主流浏览器
- js实现上传图片实时预览,兼容chrome IE firefox多浏览器
- Ext图片上传之预览
- Ext图片上传之预览 .
- 织梦,导航首页高亮解决方案
- C语言编译后生成的.exe文件单独运行的设置
- ExtJs ComboBox 动态创建下拉框
- java 日期工具类整理
- 面试题28:字符串的排列
- Ext 图片上传及预览,兼容多中浏览器
- 明明jar包已经引入了,并且编译不报错,但是运行却还提示classnotfound,什么原因?
- Jquery easyUI 数据加载loadMask遮掩效果
- html5 调起微信支付
- Mybatis 学习
- eclipse 去掉javascriptValidator
- Java WebService开发
- java 文件的操作
- java 获取异常信息