Abu Hurairah and Abu Saeed Khudri reported,

The Messenger of Allah ﷺ saw some phlegm on the wall of the mosque, so he picked up a pebble and scraped it off. Then he said, "When one of you needs to spit, let him not spit in front of him, nor to his right. Let him spit to his left, or beneath his left foot."

Azami 3124

Sahih

عن أبي هريرة وأبي سعيد قالا

إن رسول الله ﷺ رأى نخامة في جدار المسجد، فتناول حصاة فحكها فقال: إذا تنخم أحدكم فلا يتنخمن قبل وجهه، ولا عن يمينه، ليبصق عن يساره، أو تحت قدمه اليسرى.

الأعظمي 3124صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Mosques
Section
Prohibition of spitting in the masjid and towards the qibla
Numbering
Jami al-Kamil 3124 (2nd edition)
Azami 3124