问题描述
我想从 extjs 上传文件到跨域服务器 使用 form.submit()
方法.当我调用 form.submit()
时,请求将发送到我的 Restful Web 服务并且文件已成功上传.但响应在浏览器中被阻止并显示消息:Blocked a frame with origi...host:1841" from accessing a cross-origin frame.
I would like to upload files to cross domain server from extjs using form.submit()
method. When i call form.submit()
, request is going to my restful web service and file is getting uploaded successfully. But the response is blocked at the browser with message: Blocked a frame with origi…host:1841" from accessing a cross-origin frame.
从较旧的帖子和表单提交代码中,我发现 doSubmit()
正在发送 Ajax 请求而没有 cors:true
语句,因为跨域响应被阻止.
From older posts and form submit code, i found that doSubmit()
is sending the Ajax request with out cors:true
statement due to which cross domain response is blocked.
我想发送普通的ajax请求,但不知道如何通过ajax请求读取文件数据并发送到服务器.
I thought of sending normal Ajax request but dont know how the file data can be read and send to server through ajax request.
无论如何在 php 中发送文件数据到服务器作为 form.doSubmit()
吗?有人可以帮我解决这个问题吗?
Is there anyway in php to send the file data to server as form.doSubmit()
does? Can someone help me on this problem?
谢谢.
解决方案是:document.domain = document.domain 有什么作用? 和 http://codeengine.org/extjs-fileuplaod-cross-origin-frame/
推荐答案
Ajax 调用不适用于下载,我假设上传文件.
Ajax call does not work with downloading and i presume with uploading files.
您是否尝试过在 doSubmit
之前进行设置:
Have you tried to set this before doSubmit
:
Ext.Ajax.cors = true;
Ext.Ajax.useDefaultXhrHeader = false;
这篇关于extjs 文件通过表单提交上传跨域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!