问题描述
我想从 extjs将文件上传到跨域服务器使用 form.submit()
方法.当我调用 form.submit()
时,请求将转到我宁静的Web服务,并且文件已成功上传.但是,该响应在浏览器中被以下消息阻止:阻止origi…host:1841框架访问跨域框架.
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文件通过表单提交上传跨域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!