【发布时间】:2014-10-17 19:54:38
【问题描述】:
我正在使用File uploading component for Sencha Touch 在我的 sencha 项目中上传图片。 它工作正常。但是当我尝试从另一个域上传图像时,它会给出
Uncaught SecurityError: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame with origin "http://localhost" from accessing a frame with origin "http://192.168.1.45". Protocols, domains, and ports must match.
错误。
问题很清楚,所以我尝试过使用header('Access-Control-Allow-Origin: *'); 并尝试过<script type="text/javascript">document.domain = '*';</script>(两者同时使用,也不同),但没有任何反应。 ref
基本上负责图片上传的php文件工作正常,结果图片上传成功,但在sencha中没有返回json数据,所以导致错误。
这是截图
请帮我解决这个问题。
谢谢...
【问题讨论】:
-
把
header('Access-Control-Allow-Origin: *');改成这个header("Access-Control-Allow-Origin: " . $_SERVER['HTTP_ORIGIN'] . ""); -
试过但没有任何反应。 btw thnx 回复
标签: php extjs file-upload sencha-touch