Fineuploader 3.3 CORS上传失败错误IE9 IE8

时间:2013-03-17 04:02:56

标签: cors fine-uploader

我在使用FineUploader进行隐藏iframe内部的跨域(CORS)提交时遇到了问题(即IE 9,8)。对于每个跨域上传请求,图像上传成功,但显示错误消息,IE浏览器说明:

No valid message received from loaded iframe for file id 1

现在,他们的blog说:

  

所有跨域iframe启动的响应必须以上面的脚本标记结束,并且有效的JSON部分必须包含相关文件的UUID。请注意,您必须在可访问的服务器上托管iframe.xss.response.js文件,并相应地在标记中引用它。当您的响应内容返回到Fine Uploader跟踪的iframe时,将执行上面脚本标记导入的关联javascript文件,并通过window.postMessage将响应的JSON部分传递给上传者。

好的,我按照以下方式实现:

if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) 
                || (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH']!="XMLHttpRequest")){{
        header("Content-Type: text/html");
        $result['uuid'] = $uploader->gen_uuid();
        echo json_encode($result);
        echo "<script src='http://example.com/js/iframe.xss.response-3.3.0.js'></script>";
    }

现在,Fiddler说回复如下:

HTTP/1.1 200 OK
Date: Sun, 17 Mar 2013 03:26:49 GMT
Server: Apache
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: PHPSESSID=VJ3AgTRnMtjAqbxizfXBN3; path=/
Vary: Accept-Encoding
Content-Length: 203
Keep-Alive: timeout=2, max=100
Connection: Keep-Alive
Content-Type: text/html

{"success":true,"uploadName":"_73d05d51b4ab624e3260ef0b289a60bc_NMS_0785.JPG","uuid":"749174c7-e29c-485f-9f6d-cc18d4b5d0fd"}<script src='http://example.com/js/iframe.xss.response-3.3.0.js'></script>

IE调试器说:

 [FineUploader] Processing 1 files or inputs... 
 [FineUploader] Sending upload request for 1 
 [FineUploader] Received iframe load event for CORS upload request (file id 1) 
 [FineUploader] Received the following window message: '{"success":true,"uploadName":"_73d05d51b4ab624e3260ef0b289a60bc_NMS_0785.JPG","uuid":"749174c7-e29c-485f-9f6d-cc18d4b5d0fd"}' 
 [FineUploader] Received the following window message: '{"success":true,"uploadName":"_73d05d51b4ab624e3260ef0b289a60bc_NMS_0785.JPG","uuid":"749174c7-e29c-485f-9f6d-cc18d4b5d0fd"}' 
[FineUploader] No valid message received from loaded iframe for file id 1 
 [FineUploader] iframe loaded 

有没有人知道会出现什么问题?

1 个答案:

答案 0 :(得分:0)

您是否通过查看请求确认与POST请求一起发送的文件的UUID与您的响应中的UUID相匹配?最有可能的是,您在回复中发送的UUID是错误的。