protected function get_cohort_file($draftid) {
        global $USER;
        // We can not use moodleform::get_file_content() method because we need the content before the form is validated.
        if (!$draftid) {
            return null;
        }
        $fs = get_file_storage();
        $context = context_user::instance($USER->id);
        if (!$files = $fs->get_area_files($context->id, 'user', 'draft', $draftid, 'id DESC', false)) {
            return null;
        }
        $file = reset($files);

        return $file;

    }
protected function get_cohort_file($draftid) {
        global $USER;
        // We can not use moodleform::get_file_content() method because we need the content before the form is validated.
        if (!$draftid) {
            return null;
        }
        $fs = get_file_storage();
        $context = context_user::instance($USER->id);
        if (!$files = $fs->get_area_files($context->id, 'user', 'draft', $draftid, 'id DESC', false)) {
            return null;
        }
        $file = reset($files);

        return $file;

    }
protected function get_cohort_file ( $ draftid ) { global $ USER ; // We can not use moodleform::get_file_content() method because we need the content before the form is validated. if ( ! $ draftid ) { return null ; } $ fs = get_file_storage ( ) ; $ context = context_user :: instance ( $ USER -> id ) ; if ( ! $ files = $ fs -> get_area_files ( $ context -> id , 'user' , 'draft' , $ draftid , 'id DESC' , false ) ) { return null ; } $ file = reset ( $ files ) ; return $ file ; }
Returns the uploaded file if it is present.

@param int $draftid
@return stored_file|null
Returns the uploaded file if it is present .