Ben alanları arası (alt alan) yüklemeler için blueimp/jQuery-File-Upload komut dosyasını kullanabilirsiniz göndermiyor. Ana sayfa www.ornek.com ve ben st2.example.com'a dosya yüklüyorum.Ajax/JQuery istek çerezleri
Her şey gayet iyi çalışıyor ama sorun ben her ajax isteği ile çerezleri göndermemiz gereken ve nedense bu mümkün değil. Bu senaryonun belgeler diyor ki:
$('#fileupload').fileupload('option', {
xhrFields: {
withCredentials: true
}
});
:
Eğer fileupload Widget seçenek olarak ayarlayarak withCredentials $ .ajax() set, çerezler (kimlik doğrulama için örneğin) boyunca göndermeniz gerekiyorsa Bu benim için çalışmıyor. Üç farklı yerde çizgiyi
withCredentials: true
eklemeye çalıştık.:. $ ('# Fileupload') için
- fileupload ($ ('# fileupload') ile {
- FileUpload ('seçeneği', {$ .ajax için
- ({
İlk 2 hiç çalışmıyor. sadece üçüncü eserler BAŞ istekleri. BAŞ istekleri çerezleri ama SEÇENEKLER'e ve POST değil gönderin. Bunu Firefox ve Chrome'da tarayıcı konsolunda kontrol ettim.
Sorum şu: nereye SEÇENEKLER ve POST istekleri herhangi çerezleri göndermez sorundur?
Scriptim aşağıda. Bu örnek, test ettiğim 3 yerde "withCredentials: true" ifadesini içerir. st2.example.com üzerinde
<script> var defaultthumbnail = '<img class="thum5" src="/upload.png">'; $(function() { var formData = $('#fileupload').serializeArray(); 'use strict'; $('#fileupload').fileupload({ xhrFields: {withCredentials: true}, url:'//st2.example.com/', }); $('#fileupload').fileupload('option', { acceptFileTypes: /(\.|\/)(jpe?g)$/i, autoUpload:true, maxNumberOfFiles:20, maxFileSize:4000000, xhrFields: {withCredentials: true}, disableImageResize: /Android(?!.*Chrome)|Opera/ .test(window.navigator.userAgent) }); if ($.support.cors) { $.ajax({ xhrFields: {withCredentials: true}, url: $('#fileupload').fileupload('option', 'url'), type: 'HEAD' }).fail(function() { $('<div class="error"/>') .text('Server is not available') .appendTo('#fileupload'); }); } }); </script>
Dosya içeriği:
header('Access-Control-Allow-Origin: http://www.example.com'); header("Access-Control-Allow-Credentials: true"); header('Access-Control-Allow-Methods: HEAD, GET, PUT, POST, OPTIONS'); header('Access-Control-Allow-Headers: Content-Type, Content-Range, Content-Disposition, Content-Description');