The photograph above is the first surviving photo of a sitting president. James K. Polk, the 11th President of the United States, was photographed while in office on February 14, 1849. The daguerreotype was taken by famous photographer Matthew Brady in New York City. Polk was also the first president to be extensively photographed during his presidency.
Clarification: It has been stated that William Henry Harrison, the ninth President of the United States, was the first president to be photographed while in office. According to some sources, after delivering his 1841 inaugural speech (in the rain which would give him the pneumonia that would later kill him), President Harrison posed for a daguerreotype. That photograph has since been lost leaving Polk’s 1849 photograph as the first (surviving) photograph of a sitting president.