EXTJS Fileupload - IE8 安全栏问题 [英] EXTJS Fileupload - Problem with IE8 security bar

查看:18
本文介绍了EXTJS Fileupload - IE8 安全栏问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个 EXTJS 应用程序来发送带有附件的电子邮件.所以我有一个非常基本的表单,其中包括主题的文本字段、另一个带有 inputType 的文本字段:附件的文件"和一个 html 编辑器.

I'm trying to make an EXTJS application to send email with an attachment. So I have a very basic form that include textfield for the subject, another textfield with inputType: 'file' for the attachment, and an html editor.

var panel = new Ext.form.FormPanel({
    fileUpload:true,
    labelAlign: 'right',        
    monitorValid: true,
    border: false,
    bodyBorder: false,       
    defaults:{
        anchor: '100%',
        labelStyle: 'font-weight:bold;'
    },
    items: [
        {
            xtype: 'textfield',
            fieldLabel: 'SUBJECT',
            name: 'subject',
            allowBlank: false
        },
        {
            xtype: 'textfield',
            fieldLabel: 'ATTACHMENT',
            name: 'file_to_upload',
            anchor: '80%',
            itemCls: 'attachment-field',
            allowBlank: true,
            inputType:'file'
        },
        {
            xtype: 'htmleditor',
            fieldLabel:'MESSAGE',
            name:'msg'
        }
    ]
});

这个表单被放置在一个将提交给服务器的窗口中:

And this form is placed in a window which will submit to the server:

var window = new Ext.Window({
    title: 'Compose a message',
    height: 600,
    width: 800,
    autoScroll: true,
    border: false,
    bodyBorder: false,        
    items: panel,
    buttons:[
        {
            text: 'Send',
            formBind: true,
            handler: function() {
                panel.getForm().submit({
                    url: *Call to the server*,
                    method  : 'POST',
                    timeout: 300000, // 5min
                    waitMsg: 'Please wait while we send your email',                        
                    success :function(form, action) {
                        window.close();
                    }                                                
                });
            }
        },
        {
            text: 'Close',
            handler: function() {
                window.close();
            }
        }
    ]
});

当我使用 FF 将表单提交到服务器时,一切都很好.但是IE8出现问题.IE 显示安全栏说我正在尝试将文件下载到计算机,这与我正在做的事情完全相反(我正在上传文件)!

And everything works great when I submit the form to the server using FF. But a problem occurs with IE8. IE is showing the security bar saying that I'm trying to download a file to the computer, which is exactly reverse of what I'm doing ( I'm uploading a file)!

如何防止触发此安全栏?

How can I prevent triggering this security bar?

--EDIT 2010 年 12 月 18 日 16:48 EST--是否有可能是由以下原因引起的:(来自EXTJS basicForm 文档)

--EDIT December 18th, 2010 16:48 EST-- Is it possible that it can be caused by this: (comming from the EXTJS basicForm documentation)

文件上传不是使用普通的Ajax"技术执行的,也就是说它们不是使用 XMLHttpRequests 执行的.而是以标准方式提交表单,临时修改 DOM 元素以将其目标设置为引用动态生成的隐藏元素,该元素被插入到文档中,但在收集到返回数据后被删除.服务器响应由浏览器解析以创建 IFRAME 的文档.如果服务器使用 JSON 发送返回对象,则必须将 Content-Type 标头设置为text/html",以便告诉浏览器将未更改的文本插入到文档正文中.对 HTML 解析器重要的字符必须作为 HTML 实体发送,因此编码<"如<"、&"作为&"等.从文档中检索响应文本,并创建一个包含 responseText 属性的虚假 XMLHttpRequest 对象,以符合事件处理程序和回调的要求.请注意,文件上传数据包以内容类型 multipart/form 发送,某些服务器技术(特别是 JEE)可能需要进行一些自定义处理,以便从数据包内容中检索参数名称和参数值.

File uploads are not performed using normal 'Ajax' techniques, that is they are not performed using XMLHttpRequests. Instead the form is submitted in the standard manner with the DOM element temporarily modified to have its target set to refer to a dynamically generated, hidden which is inserted into the document but removed after the return data has been gathered. The server response is parsed by the browser to create the document for the IFRAME. If the server is using JSON to send the return object, then the Content-Type header must be set to "text/html" in order to tell the browser to insert the text unchanged into the document body. Characters which are significant to an HTML parser must be sent as HTML entities, so encode "<" as "<", "&" as "&" etc. The response text is retrieved from the document, and a fake XMLHttpRequest object is created containing a responseText property in order to conform to the requirements of event handlers and callbacks. Be aware that file upload packets are sent with the content type multipart/form and some server technologies (notably JEE) may require some custom processing in order to retrieve parameter names and parameter values from the packet content.

我不认为我完全理解那里的解释...

I don't think I understand everything about there explanation...

-- 结束编辑 --

谢谢阿兰

推荐答案

这是 Ext 写入文档的内容.

This is what Ext writes to the document.

<iframe id="ext-gen170" name="ext-gen170" class="x-hidden" src="about:blank"><html><head></head><body></body></html></iframe>  

这个问题可以通过设置一个有效的 https src 路径来解决,例如https://yousite.com/blank.html

This problem can be resolve by setting a valid https src path e.g. https://yousite.com/blank.html

我还没有找到如何修改 src.欢迎任何帮助

I haven't found yet how to modify the src. Any help would be welcome

这篇关于EXTJS Fileupload - IE8 安全栏问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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