gpt4 book ai didi

html - plupload跨域上传200 http错误

转载 作者:行者123 更新时间:2023-11-28 03:24:45 30 4
gpt4 key购买 nike

我想使用 plupload 库将文件上传到远程服务器。使用 html5 运行时,Chrome (32.0) 和 IE 10 一切正常,但是当我尝试使用 Firefox 27(html5 运行时)或 IE 8(html4 运行时)时,出现错误 Error #-200: HTTP Error..

客户端脚本:

$(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();
};

});

Chrome 的第一个请求:

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

Chrome 的第二个请求:

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

请求 header

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

响应头

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

服务器端脚本:

<?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)) {

使用 Firefox 时,OPTIONS 方法对请求的响应是空的,并且没有后续的 POST 请求。

这是 Firefox header :

Firefox headers

我不明白为什么它不能与 Firefox 和 IE8 一起使用。

感谢您的帮助。

[编辑] 我刚刚尝试使用 flash 运行时:它适用于 Chrome 和 IE 10,但不适用于 Firefox 和 IE8。奇怪的是 alert(info['runtime']); 没有出现但是控制台中没有 javascript 错误...

最佳答案

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

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

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.

我不得不添加一个异常(exception),它终于奏效了\o/

关于html - plupload跨域上传200 http错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21988085/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com