Eratosthenes knew that on the summer solstice at local noon on the Tropic of Cancer, the Sun would appear at the zenith, directly overhead (sun elavation of 90°) - though Syene was in fact slightly north of the tropic. He also knew, from using a vertical stick and measuring the cast shadow, that in his home town of Alexandria, the angle of elevation of the Sun would be 83° or 7° south of the zenith at the same time.
Assuming that Alexandria was due north of Syene - Alexandria is in fact on a more westerly longitude - he concluded, using geometry of parallel lines, that the distance from Alexandria to Syene must be 7/360 of the total circumference of the Earth. The distance between the cities was known from caravan travellings to be about 5,000 stadia. He established a final value of 700 stadia per degree, which implies a circumference of 252,000 stadia. The exact size of the stadion he used is no longer known (the common Attic stadion was about 185 m), but it is generally believed that Eratosthenes' value corresponds to between 39,690 km and 46,620 km. The circumference of the Earth around the poles is now measured at around 40,008 km. Eratosthenes result is not bad at all.