Get author ID with attachment ID

Back in the day I wrote a function to check for that (you can put it in functions.php and call it from your page):

public function check_if_user_is_author($user_id, $post_id) {
    global $wpdb;
    $res = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->posts ." WHERE ID = %d AND post_author = %d LIMIT 1", $post_id, $user_id));
    if(isset($res) && count($res) > 0) {
        return $res[0];
    } else {
        return false;
    }
}

Also, theoretically you could just get the post object and compare the author’s ID with the current logged in user’s ID. Disclaimer: code below is untested.

$current_user_id = get_current_user_id();
$post_data = get_post($your_att_id, ARRAY_A);
$author_id = $post_data['post_author'];
if( $current_user_id == $author_id ) {
    // good, current logged-in user is author of attachment
}