The Prophet ﷺ noticed some phlegm on the wall facing the qiblah in the mosque and scraped it off with a pebble. He then forbade a person from spitting in front of himself or to his right, instructing instead that he spit to his left or beneath his left foot.
أن النبي ﷺ أبصر نخامة في قبلة المسجد، فحكها بحصاة، ثم نهى أن يبزق الرجل بين يديه أو عن يمينه، ولكن عن يساره، أو تحت قدمه اليسرى.
Bukhari narrated it in the Book of Prayer (413), and Muslim in the Book of Mosques (548), both from the hadith of Sufyan bin Uyayna, from Zuhri, from Humayd bin Abdul-Rahman, from Abu Saeed Khudri, who mentioned the same.