Uploading a file with twig and Slim framework (Version 2) - PHP

前端 未结 1 1761
再見小時候
再見小時候 2021-01-18 05:03

I\'m using UserFrosting a user management system and I\'m having some trouble uploading a file through form post, this is what I tried

This is how my twig fi

相关标签:
1条回答
  • 2021-01-18 05:24

    This answer is assuming you're using UserFrosting, since you linked this question in the UserFrosting Gitter chat.

    UserFrosting includes CSRFGuard Middleware to make sure all POST requests originated locally. You need to include the CSRF token to ensure that the middleware does not block the POST request.

    Since the token is already in the Twig global variables, the easiest way is to use a hidden form field with the CSRF token in it:

    <input type="hidden" name="{{csrf_key}}" value="{{csrf_token}}">
    
    0 讨论(0)
提交回复
热议问题