The Prophet ﷺ saw some phlegm on the qiblah wall of the mosque and scraped it off with a pebble. He forbade anyone from spitting in front of himself or to his right, and said that one should spit to his left or beneath his left foot.
أخبرنا قتيبة قال حدثنا سفيان عن الزهري عن حميد بن عبد الرحمن
النبي ﷺ رأى نخامة في قبلة المسجد فحكها بحصاة ونهى أن يبصق الرجل بين يديه أو عن يمينه وقال يبصق عن يساره أو تحت قدمه اليسرى
Bukhari transmitted it, in the Book of Prayer, Chapter: "He should spit to his left," etc., hadith 414, and Muslim, in the Book of Masjids, Chapter on the prohibition of spitting in the masjid, etc., hadith 52/548, from the hadith of Sufyan bin Uyayna with this wording, and it is also in Al-Kubra, hadith 804.