Problem with File Field Type
Created 7 years ago by pwrobel

Hi! I've got some problem with File Field Type. I made a form which allow users to add post on blog, and there is photo field in this form. When I try to upload file via this field there is an error:

TokenMismatchException in VerifyCsrfToken.php line 68

and

http://localhost/streams/file-field_type/handle 500 (Internal Server Error).

I've got this error only in front, in back-end modules I can upload images normally.

Has anybody got this kind of problem?

ryanthompson  —  7 years ago Best Answer

Hey there! Sounds like maybe you are missing the {{ constants() }} from the header of your theme?

Then you will probably need to include this in your header as well: https://github.com/pyrocms/pyrocms-theme/blob/master/resources/js/theme/initialize.js#L3-L8

ryanthompson  —  7 years ago

Just a heads up - that snippet looks here: https://github.com/pyrocms/pyrocms-theme/blob/master/resources/views/partials/metadata.twig#L6

Just include that as well.. I may have some JS improvements to make there these will always be viable ways of doing things. I will just want to try and make it more automatic.

So constants() is not your issue in this case but 100% suggest including it cause other field types look there. In reality they all should so.. Ill be patching that initialize.js file soon.

pwrobel  —  7 years ago

Second answer helps! Thanks a lot 😄. I have constants line in my theme and initialize script included. But i miss

meta name="csrf-token" content="{{ csrf_token() }} 
line 😄. Thank you very much! 😄