Get file name upload via form api? I made a module to upload file in form, below is my code snippet, I am able to save file in proper folder but I want to get name of file uploaded so I can save it in database and make reference for it, I tried lots of thing but was not able to do it.

class MyForm extends FormBase {
  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'my_forms';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {

    $form['resume'] = array(
        '#type' =&gt; 'managed_file',
        '#title' =&gt; t('File'),
        '#required' =&gt; TRUE,
        '#upload_validators'  =&gt; array(
            'file_validate_extensions' =&gt; array('pdf doc docx'),
            'file_validate_size' =&gt; array(25600000),
        ),
        '#upload_location' =&gt; 'public://myfile/',
    );

    $form['actions']['#type'] = 'actions';
    $form['actions']['submit'] = array(
        '#type' =&gt; 'submit',
        '#value' =&gt; $this-&gt;t('Submit'),
        '#button_type' =&gt; 'primary',
    );

    return $form;
  }

  /**
   * {@inheritdoc}
   */
    public function validateForm(array &amp;$form, FormStateInterface $form_state) {

    }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &amp;$form, FormStateInterface $form_state) {
    drupal_set_message($this-&gt;t('@can_name ,Your application is being submitted!', array('@can_name' =&gt; $form_state-&gt;getValue('name'))));
    // echo file name here
   }
}
The 'managed_file' FormElement plugin specifically stores the uploaded file as a managed file entity. This plugin stores the file entity id inside form state value as part of its validation.

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &amp;$form, FormStateInterface $form_state) {
    drupal_set_message($this-&gt;t('@can_name ,Your application is being submitted!', array('@can_name' =&gt; $form_state-&gt;getValue('name'))));
    // Use the fid to load the file entity. Unfortunately ManagedFile loads the file entity, but does not store it in form state.
    $fid = $form_state-&gt;getValue('resume');
    $file = \Drupal\file\Entity\File::load($fid);
    // Do something other than "echo" $file-&gt;getFilename() here.
  }