关于ext的File Upload Field ,获取全路径或者隐藏C:\fakepath

dfggdfgd 2016-09-05 04:58:06
如题,请各位赐教!
关于ext的File Upload Field ,获取全路径或者隐藏'C:\fakepath'。
...全文
461 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
bug仁 2019-08-06
  • 打赏
  • 举报
回复
给你看下我们公司大佬写的上传图片的代码,你自己参考下:

onPhotoUpload: function () {

        var me = this;
        var myphoto = me.items.items[0].getComponent('userForm').getComponent('myphoto');
        var id = me.items.items[0].getComponent('userForm').getValues().id;

        if (Ext.isEmpty(id)) {
            EU.toastWarn("保存用户信息后再上传头像。");
            return;
        }
        var p_form = Ext.create("Ext.form.Panel", {
            layout: 'fit', items: {
                xtype: 'filefield',
                labelWidth: 70,
                emptyText: '请选择照片',
                fieldLabel: '照片',
                name: 'photofile',
                triggers: {clear: false},
                allowBlank: false,
                buttonText: '',
                buttonConfig: {iconCls: 'x-fa fa-file-image-o'}
            }
        });
        var form = p_form.getForm();
        me.winPhoto = Ext.create('Ext.window.Window', {
            title: '上传照片', height: 150, width: 500,
            layout: 'fit', bodyPadding: 5, modal: true,
            items: p_form,
            buttons: [{
                text: '清除',
                handler: function () {
                    var url = " ";
                    EU.RS({
                        url: url,
                        params: {id: id},
                        callback: function (options, success, response) {
                            if (options.success) {
                                EU.showMsg({message: options.message});
                                myphoto.setSrc('images/system/nophoto.png');
                            }
                            else {
                                EU.showError({message: options.message});
                            }
                        }
                    });
                }
            }, {
                text: '上传',
                handler: function () {
                    if (form.isValid()) {
                        p_form.submit({
                            url: "",
                            params: {id: id},
                            waitMsg: '照片上传中..',
                            timeout: 60,
                            callback: function (options, success, response) {
                                var result = JSON.parse(response.responseText);
                                if (result.success) {
                                    var src = '';
                                    EU.showMsg({message: result.message});
                                    myphoto.setSrc(src);
                                }
                                else {
                                    EU.showError({message: result.message});
                                }
                            }
                        });
                    }
                }
            }, {
                text: '关闭',
                handler: function () {
                    form.reset();
                    me.winPhoto.hide();
                }
            }]
        })
        me.winPhoto.show();
    }
weixin_43869905 2019-08-06
  • 打赏
  • 举报
回复
什么意思哦 都没听懂 你想表达的意思
qq_38662525 2019-08-06
  • 打赏
  • 举报
回复
dfggdfgd 2016-09-05
  • 打赏
  • 举报
回复
id : 'uploadid',
				selectOnFocus: true,
	        	xtype: 'fileuploadfield',   
			    fieldLabel: '文 件',   
                emptyText: '请选择excel文件',
                buttonCfg: {
                    iconCls: 'upload-icon'
                },
                anchor: '100%',
                validator: function(value){
                	//console.log(value);
                	var arr = value.split('.');
                	if(arr[arr.length-1] != 'xls' && arr[arr.length-1] != 'xlsx'){
                		return '所选文件非excel文件!';
                	}else{
                		return true;
                	}
                },
			    allowBlank: false,
			    toolTip:true
dfggdfgd 2016-09-05
  • 打赏
  • 举报
回复
无法上传图片,好郁闷。。

50,523

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧