この質問でpluploader を使用して失敗した後、現在FineUploaderを試しています。
CORS を読んだ後、IIS6 サーバーにさまざまなヘッダーを実装しました。
どうやら私のスクリプトは最初の ( preflight
) 承認リクエストを起動して失敗しますが、Chrome は 2 番目の ( standard
) リクエストの送信を許可しますが、Firefox は許可しません。これは実際には Chrome のバグだと思いますが、少なくともスクリプトがおそらく正しく動作していることを確認できました。
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
ヘッダーは、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
2つを並べて比較しようとしましたが、リクエストがエラーを返す原因となる欠落しているヘッダーが見つかりません403 Forbidden
。
コードが多いため、PHP ソースは含めていません。Chrome で動作し、ファイルが正しくアップロードされているので、スクリプトは正しいはずです。言及する価値がある唯一のこと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
}
});
誰でも助けることができますか?私は今日、この 1 つの問題に文字通り 8 時間費やしました。
前もって感謝します、