How to solve the "No file was uploaded." when trying to use custom form field?
For saving file u can use

    $form['test_picture']['file'] = array(
        '#type' =&gt; 'managed_file',
        '#title' =&gt; t('Test Picture'),
        '#description' =&gt; t('Allowed extensions: gif png jpg jpeg'),            
        '#upload_location' =&gt; variable_get('picture_upload_location'),
        '#upload_validators' =&gt; array(
            'file_validate_extensions' =&gt; array('pdf'),
            'file_validate_size' =&gt; array(MAX_FILE_SIZE*1024*1024),
        ),
    );