Mass/Bulk assign featured images to posts

As you don’t have much programming experience, I’ll post a ready-to-use solution here. I’ve looked at your code a little longer, and the problem is that after array_shift, $ids is still an array. set_post_thumbnail expects and integer, not an array. You could use $ids[0] as the second parameter, but the following is a cleaner solution, in my opinion.

function wpse149149_addimg() {
    $fh = @fopen( dirname( __FILE__ ) . '/addimg.txt', 'r' );

    if ( $fh ) {
        while ( ( $line = fgets( $fh ) ) !== false ) {
            $ids = explode( ',', $line );
            array_walk( $ids, 'trim' );
            set_post_thumbnail( $ids[0], $ids[1] );
        }
    }
}

add_action( 'wp_head', 'wpse149149_addimg' );