File upload through form type file My Drupal version is 8.6.10

I am trying to upload a file through the file_save_upload function and the function is looking for the file in 

Symfony\Component\HttpFoundation\FileBag Object

$all_files = \Drupal::request()-&gt;files;
debug($all_files);

Symfony\Component\HttpFoundation\FileBag Object
(
    [parameters:protected] =&gt; Array
        (
        )

)


But my file is in 

Symfony\Component\HttpFoundation\ParameterBag Object.

$all_files = \Drupal::request()-&gt;request;
debug($all_files);

Symfony\Component\HttpFoundation\ParameterBag Object
(
    [parameters:protected] =&gt; Array
        (
            [name] =&gt; 
            [type] =&gt; 4
            [files] =&gt; Array
                (
                    [image_section] =&gt; logo_capnord.png
                )

            [op] =&gt; Ajouter
            [form_build_id] =&gt; form-wMTrCGaN5mPlOOv8bqS7UsJ0lRiSN6QQp9UviA0cTIA
            [form_token] =&gt; 1hTMXJRfoQvFV9Lqq3TuJ29eYC6L-zt3U7Bow1P8yJ0
            [form_id] =&gt; capnord_section_form_list
        )

)


The field is generated through the reloading of the form in ajax.

  $form["base"]["fields"] += [
    "image_section" =&gt; [
      "#type" =&gt; "file",
      "#title" =&gt; "Image",
    ]
  ];
Solution

$form["#attributes"] = ["enctype" =&gt; "multipart/form-data"];

$form["base"]["fields"] += [
   "image_section" =&gt; [
    "#type" =&gt; "file",
    "#title" =&gt; "Image",
   ]
];


I solved my problem, as I only reloaded one part of the form, the form generator did not know that there was a file element, so it did not add "multipart enctype / form-data" to the form.

I hope this will help someone in the same situation as me in the future.