Abu Hurairah reported,

The Messenger of Allah ﷺ saw some phlegm on the prayer wall of the mosque. He turned to the people and said, "What is it with one of you who stands facing his Lord and then spits in front of Him? Would any of you like to be faced and have someone spit in his face? When one of you needs to spit, let him spit to his left under his foot. If he cannot, then let him do like this." Qasim then demonstrated by spitting into his garment and rubbing one part of it against another.

Muslim 1228

Sahih

حدثنا أبو بكر بن أبي شيبة وزهير بن حرب جميعا عن ابن علية قال زهير حدثنا ابن علية عن القاسم بن مهران عن أبي رافع

عن أبي هريرة

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

مسلم 1228صحيح
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 1228
Muslim 1228