Allow Author on Site A capability to upload files on Site B in Multi Site

I have a multisite.
In Site A, a user is logged in as author.

In Site B, user is still logged without role, but he can’t upload file in a front end form (made in ACF).

I need that user only logged in Site A, can upload file in this front end form in Site B.
I have tried with two solutions:

if ( is_user_logged_in() )
 add_action('admin_init', 'allow_contributor_uploads');

function allow_contributor_uploads() {
 $user_id = get_current_user_id();
 $user_id->add_cap( 'upload_files');

}

and

if ( is_user_logged_in() )
   add_action('admin_init', 'allow_uploads');
function allow_uploads() {
   global $current_user;
   $current_user = get_current_user_id();
   $current_user->add_cap( 'upload_files');
}

Solutions Collecting From Web of "Allow Author on Site A capability to upload files on Site B in Multi Site"

Look into switch_to_blog() and its required follow up, restore_current_blog()

I left comments in code for basic idea to adapt into your function.

It may need tweaking, and can probably be improved.

//Site B
add_action( 'init', 'site_a_author_upload_site_b' );

function site_a_author_upload_site_b() {
    if ( is_user_logged_in() ) {
       //get a WP_User object of current user
       $current_user = wp_get_current_user();

       //ID of Site A
       $site_a = 1;

       //Switch to Site A
       switch_to_blog( $site_a );

       //get current user's roles on Site A
       $get_role = $current_user->roles;

       //Check if logged in user is an author on Site A
       if ( in_array( 'author', $get_role ) ) {

           //if yes, let's 1) restore current blog (Site B)
           restore_current_blog();

           //and 2) Add the cap we want to add to Wp_User object
           $current_user->add_cap( 'upload_files' );
       }

       else {

        //be sure we have restored current blog
        restore_current_blog();
      }
   }//end if logged in


}//end site_a_author_upload_site_b()