I have a form built with Drupal 8 FAPI. It's a sophisticated "contact us" type thing which includes the ability to upload files.
Among other things it includes several managed_file elements.
The elements are defined in buildForm() like this.
$form['myfile'] = [ '#type' => 'managed_file', '#upload_location' => 'public://' . date('Y-m') ];
In submitForm() I look at $form_state->get('myfile'). If I'm logged in as admin (haven't tried other roles) this contains an array with one element who's value is the id of the created file entity. That all works well.
If I am not logged in, $form_state->get('myfile') is an empty array in submitForm().
With anonymous, the file is successfully uploaded because it physically appears in /sites/default/files/2016-05. The file entity is created because I can see it in /admin/content/files.
I must be missing something related to permissions. I tried adding '#access' => true to my form element definition but that did not help.
I have a content entity which includes a file field. The add entity form derived from ContentEntityForm is basically the same as my form and works correctly even for anonymous. I probably could use that instead of my form but I prefer to use my own form. This is partially a learning exercise.
Thanks for any help.