Drupal 8 upload document through input type file?

2017-09-21 13:17:17

I am trying to build a form with input type file and upload the document on form submission. So, for the upload to happen the form should have multipart/form-data, is there a way to include it in drupal 8? or is there any other method to upload a document only on form submit?

I know Drupal has managed_file but it uploads the document to temp location on selecting a file and I dont want to use it.

$form['document'] = [

'#type' => 'file',

'#multiple' => FALSE,

'#title' => t('Upload Document')