Fulham claimed a crucial 2-1 win over 10-man West Ham United as they climbed out of the Premier League's bottom three.