Abu Hurairah and Abu Saeed Khudri reported,

The Messenger of Allah ﷺ saw some phlegm on the wall facing the qiblah in the masjid, so he scraped it off with a pebble. He then forbade anyone from spitting to his right or in front of him, instructing instead that he spit to his left or under his left foot.

Muslim 1226

Sahih

حدثني أبو الطاهر وحرملة قالا حدثنا ابن وهب عن يونس قال ح و حدثني زهير بن حرب حدثنا يعقوب بن إبراهيم حدثنا أبي كلاهما عن ابن شهاب عن حميد بن عبد الرحمن أن أبا هريرة وأبا سعيد أخبراه أن رسول الله ﷺ رأى نخامة بمثل حديث ابن عيينة

مسلم 1226صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Muslim
Book
Mosques and places of prayer
Chapter
Prohibition of spitting in the masjid during prayer and otherwise
Numbering
Darussalam 1226
Muslim 1226