Alfresco Update File - ERROR POST

后端 未结 2 1465
说谎
说谎 2021-01-24 14:01

I\'m trying to update a file in Alfresco... And I make this code:

var csrf_header = Alfresco.util.CSRFPolicy.getHeader();
var csrf_token = Alfresco.util.CSRFPoli         


        
2条回答
  •  忘掉有多难
    2021-01-24 14:35

    Instead of setting the header, pass the token on the url:

    if (Alfresco.util.CSRFPolicy && Alfresco.util.CSRFPolicy.isFilterEnabled())
    {
       url += "?" + Alfresco.util.CSRFPolicy.getParameter() + "=" + encodeURIComponent(Alfresco.util.CSRFPolicy.getToken());
    }
    

    As described in CSRF Policy

    When uploading a file by submitting a form with enctype multipart/form-data it is not possible to set a header on the request, the reason is not because of the enctype specifically but due to the fact that its not possible to set a header on any form submission in the browser.

    The other solution is to use Alfresco.forms.Form that takes care of everything.

提交回复
热议问题