FineUploader - add authentication in header

后端 未结 1 665
一向
一向 2021-01-12 07:06

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 w

相关标签:
1条回答
  • 2021-01-12 07:50

    Your 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 common 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.

    0 讨论(0)
提交回复
热议问题