澳门金莎娱乐手机版 服务器 网上找了好多EXTJS上传图片预览的澳门金莎娱乐手机版

网上找了好多EXTJS上传图片预览的澳门金莎娱乐手机版

复制代码 代码如下: { width: 450,
fileUpload: true, 田野先生Label: ‘选拔图片’, items: [{ xtype: ‘textfield’,
id: ‘up_forth’, name: ‘up_网上找了好多EXTJS上传图片预览的澳门金莎娱乐手机版。forth’, inputType: ‘file’, width: 300 }] }
预览box 复制代码 代码如下: { columnWidth:
.18, bodyStyle: ‘ margin:4px 10px 10px 5px’, layout: ‘form’, items: [{
xtype: ‘box’, autoEl: { width: 150, height: 150, tag: ‘div’, id:
‘browser_up_forth’ } }] } myfrom表示上传控件外围的FormPanel,,
contril_id表示上传控件的ID,只要在先后上预览注册该方法就能够,preview ;
复制代码 代码如下: var preview = function
{ var img_reg = /.{1}$|.{1}$|.{1}$|.{1}$|.{1}$/
myform.on(‘render’, function { myform.form.findField.on {
Ext.get.on(‘change’, function (field, newValue, oldValue) { var obj =
Ext.get.dom; var url = getFullPath; if { var newPreview =
Ext.get(‘browser_’ + control_id).dom; var showPic =
Ext.get(“showPic_” + control_id); if {
showPic.remove();//删除原来的图样 } var imgDiv = document.createElement;
imgDiv.id = “showPic_” + control_id; document.body.appendChild;
imgDiv.style.width = “150px”; imgDiv.style.height = “150px”;
imgDiv.style.filter =
“progid:DXImageTransform.Microsoft.AlphaImageLoader”;
imgDiv.filters.item(“DXImageTransform.Microsoft.AlphaImageLoader”).src =
url; newPreview.appendChild; }, this); }, this); } //获得图片地址
function getFull帕特h { // ie if (window.navigator.userAgent.indexOf {
obj.select(); return document.selection.createRange().text; } // firefox
else if (window.navigator.userAgent.indexOf { if { return
obj.files.item; } return obj.value; } return obj.value; } }

网络找了比超级多EXTJS上传图片预览的,但都特别,,,上边即便IE8能够但必然还设有其余浏览器的宽容性难点,待搁应付一下呢。。

{
               width: 450,
               fileUpload: true,
               田野先生Label: ‘选用图片’,
               items: [{
                   xtype: ‘textfield’,
                   id: ‘up_forth’,
                   name: ‘up_forth’,
                   inputType: ‘file’,
                   width: 300
               }]
}

预览box

{
                   columnWidth: .18,
                   bodyStyle: ‘ margin:4px 10px 10px 5px’,
                   layout: ‘form’,
                   items: [{
                       xtype: ‘box’,
                       autoEl: {
                           width: 150, height: 150,
                           tag: ‘div’,
                           id: ‘browser_up_forth’
                       }
                   }]
}

 

myfrom表示上传控件外围的FormPanel,,
contril_id表示上传控件的ID,只要在前后相继上预览注册该方式就能够,preview
(myfrom,’up_forth’ );

var preview = function (myform, control_id) {
    var img_reg =
/.([jJ][pP][gG]){1}$|.([jJ][pP][eE][gG]){1}$|.([gG][iI][fF]){1}$|.([pP][nN][gG]){1}$|.([bB][mM][pP]){1}$/
    myform.on(‘render’, function (f) {
        myform.form.findField(control_id).on(‘render’, function () {
            Ext.get(control_id).on(‘change’, function (field, newValue,
oldValue) {
                var obj = Ext.get(control_id).dom;
                var url = getFullPath(obj);
                if (img_reg.test(url)) {
                    var newPreview = Ext.get(‘browser_’ +
control_id).dom;
                    var showPic = Ext.get(“showPic_” + control_id);
                    if (showPic != null) {
                        showPic.remove();//删除原来的图样www.2cto.com
                    }
                    var imgDiv = document.createElement(“div”);
                    imgDiv.id = “showPic_” + control_id;
                    document.body.appendChild(imgDiv);
                    imgDiv.style.width = “150px”;
                    imgDiv.style.height = “150px”;
                    imgDiv.style.filter =
“progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod =
scale)”;
                   
imgDiv.filters.item(“DXImageTransform.Microsoft.AlphaImageLoader”).src =
url;
                    newPreview.appendChild(imgDiv);
                }
            }, this);
        }, this);
    }, this);
}

//获得图片地址
function getFullPath(obj) {
    if (obj) {
        // ie
        if (window.navigator.userAgent.indexOf(“MSIE”) >= 1) {
            obj.select();
            return document.selection.createRange().text;
        }
        // firefox
        else if (window.navigator.userAgent.indexOf(“Firefox”) >= 1)
{
            if (obj.files) {
                return obj.files.item(0).getAsDataURL();
            }
            return obj.value;
        }
        return obj.value;
    }
}

 

摘自  KimhillZhang 

{ width:…

标签:

发表评论

电子邮件地址不会被公开。 必填项已用*标注

相关文章

网站地图xml地图