删除extjs中的伪路径 [英] Remove fake path in extjs

查看:107
本文介绍了删除extjs中的伪路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是extjs的新手.请帮助我删除filefield中的fakepath问题.我不想获取确切的路径.删除"fakepath"字符串对我来说是可以的.代码运行完美,但路径显示为C:\ fakepath.... 我创建了一个单独的窗口以上传文件.在我的情况下,由于从菜单中选择了一个选项,因此应用程序应该有一个单独的窗口. 这是我的代码的crateWindow函数:

I am new to the extjs.Please help me to remove fakepath issue in filefield.I do not want to get the exact path .Removing "fakepath" string is ok for me. Code runs perfectly but path displays as C:\fakepath.... I created a seperate window inorder to upload a file. In my case Application should have a seperate window as a result of selecting a option from the menu. Here is crateWindow function of my code :

    createWindow: function() {
    var desktop = teamApp.getDesktop();
    var win = desktop.getWindow(this.windowId + '_win');
    if(!win) {
        win = desktop.createWindow({
            id: this.windowId + '_win',
            title: 'Upload a Audio',
            iconCls: 'icon-upload-picture',
            height:150,
            width: 500,                
            layout: 'fit',
            renderTo: Ext.getBody(),
            items:
            {
                xtype: 'panel',
                frame:true,
                bodyPadding: '10',
                items: [{
                    xtype: 'filefield',
                    id: 'form-file',
                    labelWidth: 100,
                    //emptyText: 'Select an audio file',
                    fieldLabel: 'Audio File',
                    name: 'file-path',
                    fieldWidth: 250,
                    allowBlank: false,
                    anchor: '100%',
                    buttonText: 'Browse'
                }],

                buttons: [{
                    text: 'Save',
                    handler: function(){
                        var form = this.up('form').getForm();
                        if(form.isValid()){
                            form.submit({
                                //url: 'file-upload.php',
                                waitMsg: 'Uploading your Audio file...',
                                success: function(fp, o) {
                                    msg('Success', 'Processed file "' + o.result.file + '" on the server');
                                }
                            });
                        }
                    }
                }]
            }
        })
    }
    win.show();
    return win;
}

推荐答案

据我了解,根据

因为没有安全的跨浏览器方法来以编程方式设置文件输入的值,所以未实现标准的Field setValue方法. getValue方法将返回一个与浏览器相关的值.有些仅具有文件名,有些具有完整路径,有些使用伪造路径.

Because there is no secure cross-browser way to programmatically set the value of a file input, the standard Field setValue method is not implemented. The getValue method will return a value that is browser-dependent; some have just the file name, some have a full path, some use a fake path.

更新

您可以做的是将fieldWidth设置为零,并在文件字段之前添加另一个文本字段.您可以通过侦听文件字段的更改并解析从\的最后一个索引到最后一个的值,来将此文本字段的值设置为用户选择的文件名.

What you can do is set fieldWidth to zero and add another textfield before the filefield. You can set the value of this textfield as the name of file selected by user by listening to change of file field and parsing the value from last index of \ till last.

这篇关于删除extjs中的伪路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆