A photocell operates based on the photoelectric effect, which occurs when light of sufficient frequency (or energy) shines on the surface of a material, typically a metal.
The energy from the incident photons is absorbed by the electrons in the material. If this energy exceeds the material's work function (the minimum energy required to free an electron), electrons are emitted from the surface.
These emitted electrons produce a current when collected, and this current varies with the intensity and frequency of the incident light.
Thus, a photocell converts light energy into electrical energy using the photoelectric effect.