xhr send - send file and CSRF token

后端 未结 1 1873
无人及你
无人及你 2021-01-24 05:45

I\'m trying to use XMLHttpRequest to send a file object and a string (CSRF Token) to the server but I cant seem to figure out how to add the token:

xhr.open(\"PO         


        
相关标签:
1条回答
  • 2021-01-24 06:17

    Why don't you just add

    xhr.setRequestHeader('X-CSRF-TOKEN', '<YOURTOKENHERE>');
    

    before xhr.send() ?

    As far as I understand your problem, this should solve it. (Might be I misunderstood, though)

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