admin管理员组文章数量:1277273
I'm using FineUploader 3.7 in cross domain uploading project. Everything is fine until I move the code to client's DEV server which has simple authentication. Is there a way to embed authentication information in the form when the preflight request is sent to the server?
I have tried to embed basic auth in headers, however not working. Please refer to the code below:
$.ajaxSetup({
headers: {
'Authorization': "Basic YZVjaGFmbWluOkNieWxjBTY3"
},
beforeSend: function (jqXHR, settings) {
jqXHR.setRequestHeader('Authorization', 'Basic YZVjaGFmbWluOkNieWxjBTY3');
}
});
And even more, I have tried to set the custom header and no luck:
var manualuploader = new qq.FineUploader({
customHeaders: {
'Authorization': 'Basic YXVjaGFkbWluOkNieWxjZTY3'
},....
I'm using FineUploader 3.7 in cross domain uploading project. Everything is fine until I move the code to client's DEV server which has simple authentication. Is there a way to embed authentication information in the form when the preflight request is sent to the server?
I have tried to embed basic auth in headers, however not working. Please refer to the code below:
$.ajaxSetup({
headers: {
'Authorization': "Basic YZVjaGFmbWluOkNieWxjBTY3"
},
beforeSend: function (jqXHR, settings) {
jqXHR.setRequestHeader('Authorization', 'Basic YZVjaGFmbWluOkNieWxjBTY3');
}
});
And even more, I have tried to set the custom header and no luck:
var manualuploader = new qq.FineUploader({
customHeaders: {
'Authorization': 'Basic YXVjaGFkbWluOkNieWxjZTY3'
},....
Share
Improve this question
edited Dec 9, 2017 at 17:24
Francisco
11.5k6 gold badges37 silver badges46 bronze badges
asked Aug 27, 2013 at 4:11
PengPeng
3453 silver badges9 bronze badges
1 Answer
Reset to default 13Your customHeaders
option isn't defined properly. customHeaders
is a property of the request
option, as detailed in the request
option documentation.
Your Fine Uploader integration code should look like this instead:
var manualuploader = new qq.FineUploader({
request: {
endpoint: "path/to/your/server",
customHeaders: {
"Authorization": "Basic YXVjaGFkbWluOkNieWxjZTY3"
}
}
});
Also, please keep in mind that jQuery's ajaxSetup
has no effect on Fine Uploader's ajax/xhr calls. Fine Uploader does not use jQuery at all internally. The optional jQuery plug-in offered by Fine Uploader simply wraps the native javascript library to allow it to be easily used as a jQuery plug-in by supporting syntax mon associated with jQuery and jQuery plug-ins.
Also, please be aware that these headers will not be passed along with the upload request in IE9 and older, since IE9 and older do not support uploads via ajax/xhr. In those browsers, a form, targeting an iframe, is submitted. In the case of a form submit, there is no way to associate custom headers with the request.
本文标签: javascriptFineUploaderadd authentication in headerStack Overflow
版权声明:本文标题:javascript - FineUploader - add authentication in header - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741289597a2370471.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论