Admin page: form with enctype=”multipart/form-data” does not transfer its data

If you want to upload in a custom folder you can use the following function. Add the function in functions.php

function upload_user_file( $file = array(),$path ) {
    if(!empty($file)) 
    {


        $upload_dir=$path;
        $uploaded=move_uploaded_file($file['tmp_name'], $upload_dir.$file['name']);
        if($uploaded) 
        {
            echo "uploaded successfully ";

        }else
        {
            echo "some error in upload " ;print_r($file['error']);  
        }
    }

}

Make a form in your template file like this:

<form action="" method="post" enctype="multipart/form-data">
    <input type="file" name="file">
    <input type="submit" name="upload">
</form>

Call the upload function in template file like before get_header() function:

if(isset($_POST['upload']))
    {

       if( ! empty( $_FILES ) ) 
       {
          $file=$_FILES['file'];   // file array
          $upload_dir=wp_upload_dir();
          $path=$upload_dir['basedir'].'/myuploads/';  //upload dir.
          if(!is_dir($path)) { mkdir($path); }
          $attachment_id = upload_user_file( $file ,$path);

       }
    }