A lot of older cameras (and early phones too) would have a small mirror next to the lens, specifically for taking photos like that. The word selfie is kind of recent. The concept of taking a photo of yourself is probably as old as the invention of the camera.