A Brooklyn high school freshman took advantage of the newly lifted cellphone ban by snapping an up-skirt shot of a teacher — and the photo was shared by his classmates on Facebook, The Post has learned.

The 15-year-old student secretly took the picture with his iPhone as the newly hired teacher stood at a chalkboard at John Dewey High School in Gravesend last week, school sources said.

The freshman’s fellow students ratted out the teen to school officials Thursday after the image made the rounds on social media.

That day, the teen was sent to the principal’s office, sources said.

Police and officials from the city Department of Education were called to the school to investigate.

“It’s outrageous to have a kid take an inappropriate cellphone picture of a teacher,” a Dewey teacher said Monday. “This is something that should never happen.”

A citywide ban on cellphones on school grounds was lifted on March 2, less than two months after Mayor Bill de Blasio announced a plan to overturn the rule.

The rules now vary by school. Students at Dewey are permitted to bring their cellphones to school as long as the devices are turned off and stowed in their backpacks or lockers throughout the day.

“A lot of teachers are concerned about the lifting of the ban,” a staffer said. “It has really traumatized the teacher.”

The teacher, hired recently to replace a Spanish instructor who died, was in school on Monday but felt violated and was worried that the photo would explode on social media.

Her peeved parents even showed up at the school, threatening to sue the city.

Dewey’s principal, Kathleen Elvin, has not addressed the issue with either teachers or students, staff sources said.

But the boy’s mother stood by her son on Monday, blaming his behavior on the teacher’s choice of attire.

“The teacher was dressed inappropriately,” she told The Post.

But students who have seen the teacher around campus said she wore appropriate clothes.

“She dresses normally,” one student said. “I mean, to me, she doesn’t stand out too much. She just looks young.”

The city Department of Education confirmed the up-skirt incident, saying that it was taking the matter seriously and that appropriate actions have been taken.

One teacher walking out of the high school Monday afternoon said it was not the cellphone policy educators need to be worried about.

“The rules are fine — some kids have bad manners,” the staffer said.