使用 pluploader 失败后这个问题 https://stackoverflow.com/questions/16144879/plupload-runtimes-returning-403-forbidden-error-when-trying-to-access-upload-php,我现在正在尝试精品上传器 http://fineuploader.com/.
阅读完 CORS 后,我在 IIS6 服务器上实现了各种标头。
似乎发生的是我的脚本触发第一个(preflight
) 授权请求,该请求失败,但 Chrome 允许第二个 (standard
) 仍然请求发送 - Firefox 不会。我认为这实际上是 Chrome 的一个错误,但至少它让我知道我的脚本是probably工作正常。
这是在 Chrome 和 FF 中看到的第一个(预检)请求:
OPTIONS /frog/LOTS/upload/php.php HTTP/1.1
Host: staff.curriculum.local
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:14.0) Gecko/20100101 Firefox/14.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Origin: http://frogserver.curriculum.local
Access-Control-Request-Method: POST
Access-Control-Request-Headers: cache-control,x-requested-with
Pragma: no-cache
Cache-Control: no-cache
The Access-Control...
标头是我添加到 IIS 中的标头。
这是我的响应标题:
HTTP/1.1 403 Forbidden
Content-Length: 1758
Content-Type: text/html
Server: Microsoft-IIS/6.0
x-powered-by: ASP.NET
Access-Control-Allow-Origin: http://frogserver.curriculum.local
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Cache-Control
Access-Control-Allow-Methods: OPTIONS, GET, POST
Access-Control-Expose-Headers: Origin, X-Requested-With
Date: Mon, 22 Apr 2013 15:19:20 GMT
我试图并排比较两者,但我找不到任何丢失的标头,这会导致preflight
请求返回一个403 Forbidden
error.
我没有包含我的 PHP 源代码,因为它有很多代码。可以说它在 Chrome 中确实有效并且文件已正确上传,因此该脚本should是正确的。唯一值得一提的是我有一个header("Content-Type: text/plain");
在我的脚本的开头。将其更改为text/html
对于 Chrome 和 FireFox 来说没有区别。
JavaScript 非常简单:
$('#jquery-wrapped-fine-uploader').fineUploader({
request: {
endpoint: 'http://staff.curriculum.local/frog/LOTS/upload/php.php'
},
cors: {
expected: true, //all requests are expected to be cross-domain requests
sendCredentials: true //if you want cookies to be sent along with the request
}
});
有人可以帮忙吗?今天我在这个问题上花了整整 8 个小时,我>
提前致谢,