How to upload file from a custom module?
If you upload a file, it stores the file temporarily in file_managed table in database.And you have to set the file permanent status 1 to save it permanently else it will be deleted from the table by cron after some time.
This sample code to load a image and save it to database might help you to understand. 

/* Fetch the array of the image file stored temporarily in database */
$image = $form_state-&gt;getValue ('image');

/* Load the object of the image file by it's fid */
$file = File::load ($image[0]);

/* Set the status flag permanent of the image file object */
$file-&gt;setPermanent();

/* Save the file in database ( "managed_file" table) */
$file-&gt;save();


when you select any file from 'managed_file' field type, drupal make a entry in 'file_managed' table, you just have to set the permanent flag as above to decide whether you have to save it permanently or not.