Plupload crossdomain上传200 http错误 [英] Plupload crossdomain upload 200 http error

查看:3118
本文介绍了Plupload crossdomain上传200 http错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用plupload库将文件上传到远程服务器。一切工作与Chrome(32.0)和IE 10使用HTML5运行时,但是当我尝试使用Firefox 27(HTML5运行时)或IE 8(HTML4运行时),我得到一个错误错误#-200:HTTP错误。



客户脚本:

  $(function(){
var uploader = new plupload.Uploader({
browse_button:'browse',
url:'https://remote.com/API/action.php' ,
运行时:'html5,flash,silverlight,html4',
flash_swf_url:'./js/Moxie.swf',
silverlight_xap_url:'./js/Moxie.xap'

uploader.init();
uploader.settings.multipart_params = {
[...]
};

// PreInit事件,绑定在任何内部事件之前
uploader.bind('init',function(up,info){
console.log('[Init]','Info:' ,info,'Features:',up.features);
alert(info ['runtime']);
});

uploader.bind('Error',函数(up,err){
doc ument.getElementById('console')。innerHTML + =\\\
Error#+ err.code +:+ err.message;
});

document.getElementById('start-upload')。onclick = function(){
uploader.start();
};

});

首先请求Chrome:

<$ p $请求URL:https://remote.com/API/action.php
请求方法:OPTIONS
状态码:200 OK

 请求

$ b URL:https://remote.com/API/action.php
请求方法:POST
状态码:200 OK


$ b $ p

请求头

 接受:* / * 
Accept-Encoding: gzip,deflate,sdch
Access-Control-Request-Headers:content-键入
访问控制请求方法:POST
Cache-Control:no-cache
连接:keep-alive
主机:hipt.ucc.ie
起源:http://server.com
Pragma:no-cache
Referer:XXX
User-Agent:Mozilla / 5.0(Windows NT 6.2; WOW64)AppleWebKit / 537.36(KHTML,像Gecko )Chrome / 32.0.1700.107 Safari / 537.36

响应头

 访问s-Control-Allow-Headers:Content-Type,Authorization,X-Requested-With 
Access-Control-Allow-Methods:GET,PUT,POST,DELETE,OPTIONS
Access-Control-Allow-来源:*
Access-Control-Max-Age:1000
Cache-Control:no-cache
连接:关闭
Content-Length:5
Content-Type :text / html的; charset = UTF-8
日期:2014年2月24日星期一11:57:54 GMT
服务器:Apache / 2.2.3(CentOS)
X-Powered-By:PHP / 5.1。 6

服务器端脚本:

 <?php 

header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Methods:GET,PUT,POST,DELETE,OPTIONS');
header('Cache-Control:no-cache');
header('Access-Control-Max-Age:1000');
header('Access-Control-Allow-Headers:Content-Type,Authorization,X-Requested-With');
$ b $ if(!empty($ _ FILES)){

OPTIONS 方法的请求的响应是空的,没有下面的 POST 请求。



以下是Firefox标题:


我不明白为什么它不适用于Firefox和IE8。



感谢您的帮助。
$ b

我刚刚尝试过使用Flash运行时:它与Chrome和IE 10一起使用,但与Firefox和IE8不兼容。奇怪的是, alert(info ['runtime']); 不会出现,但控制台中没有javascript错误...

解决方案

好吧,我终于找出为什么它不工作。我使用wireshark进行了检查,发现有一个加密警报

然后我检查远程证书服务器使用: http://www.sslshopper.com/ssl-checker.html 和得到这个答案:


证书在所有网页浏览器中不被信任。您可能需要安装中间体/链式证书才能将其链接到受信任的根证书。详细了解这个错误。解决这个问题的最快方法就是联系你的SSL提供商。

我不得不添加一个异常,最后它工作了\o /


I would like to upload files to a remote server using the plupload library. Everything works with Chrome (32.0) and IE 10 using the html5 runtime but when I try with Firefox 27 (html5 runtime) or IE 8 (html4 runtime) I get an error Error #-200: HTTP Error..

Clientside script :

$(function() {
var uploader = new plupload.Uploader({
    browse_button: 'browse',
    url: 'https://remote.com/API/action.php',
    runtimes : 'html5,flash,silverlight,html4',
    flash_swf_url : './js/Moxie.swf',
    silverlight_xap_url : './js/Moxie.xap'
});

uploader.init();
uploader.settings.multipart_params = { 
       [...]
};

// PreInit events, bound before any internal events
uploader.bind('init', function(up, info) {
        console.log('[Init]', 'Info:', info, 'Features:', up.features);
        alert(info['runtime']);
});

uploader.bind('Error', function(up, err) {
    document.getElementById('console').innerHTML += "\nError #" + err.code + ": " + err.message;
});

document.getElementById('start-upload').onclick = function() {
    uploader.start();
};

});

First request with Chrome :

Request URL:https://remote.com/API/action.php
Request Method:OPTIONS
Status Code:200 OK

Second request with Chrome :

Request URL:https://remote.com/API/action.php
Request Method:POST
Status Code:200 OK

Request Headers

Accept:*/*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
Access-Control-Request-Headers:content-type
Access-Control-Request-Method:POST
Cache-Control:no-cache
Connection:keep-alive
Host:hipt.ucc.ie
Origin:http://server.com
Pragma:no-cache
Referer: XXX
User-Agent:Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36

Response Headers

Access-Control-Allow-Headers:Content-Type, Authorization, X-Requested-With
Access-Control-Allow-Methods:GET, PUT, POST, DELETE, OPTIONS
Access-Control-Allow-Origin:*
Access-Control-Max-Age:1000
Cache-Control:no-cache
Connection:close
Content-Length:5
Content-Type:text/html; charset=UTF-8
Date:Mon, 24 Feb 2014 11:57:54 GMT
Server:Apache/2.2.3 (CentOS)
X-Powered-By:PHP/5.1.6

Serverside script :

<?php

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
header('Cache-Control: no-cache');
header('Access-Control-Max-Age: 1000');
header('Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With');

if (!empty($_FILES)) {

With Firefox the response to the request with the OPTIONS method is empty and there is no following POST request.

Here are the Firefox headers:

I cannot figure out why it is not working with Firefox and IE8.

Thanks for your help.

[EDIT] I just tried with flash runtimes: same thing it works with Chrome and IE 10 but not with Firefox and IE8. The weird thing is that the alert(info['runtime']); does not appear but there is no javascript error in the console...

解决方案

Ok so I finally find out why it wasn't working. I checked using wireshark and I noticed that there was an encrypted alert.

I then check the certificate of the remote server using : http://www.sslshopper.com/ssl-checker.html and got this answer :

The certificate is not trusted in all web browsers. You may need to install an Intermediate/chain certificate to link it to a trusted root certificate. Learn more about this error. The fastest way to fix this problem is to contact your SSL provider.

I had to add an exception and it finally worked \o/

这篇关于Plupload crossdomain上传200 http错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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