I have a file upload (managed_file) in the buildForm.
$form['upload_file'] = array( '#type' => 'managed_file', '#upload_location' => $destination . 'channel' . '/' . $cid, '#attributes' => array('class' => array('ol_fileupload alert alert-default')), );
And in the submitForm I have:
/* Fetch the array of the file stored temporarily in database */ $image = $form_state->getValue('upload_file'); /* Load the object of the file by it's fid */ $file = File::load($image); $getType = $file->getMimeType(); $getUrl = $file->getFileUri();
I’ve been struggling for hours, can someone help me?