Anas bin Malik reported,

The Prophet ﷺ saw some phlegm on the wall facing the qiblah, and this distressed him so much that the displeasure showed on his face. He stood up and scraped it off with his own hand, then said, "When one of you stands in prayer, he is conversing with his Lord," or he said, "his Lord is between him and the qiblah, so none of you should spit in the direction of the qiblah. Rather, let him spit to his left or under his foot."Then he took the edge of his cloak, spat into it, and folded one part of it over the other, saying, "Or let him do like this."

Bukhari 405

Sahih

حدثنا قتيبة قال حدثنا إسماعيل بن جعفر عن حميد

عن أنس بن مالك

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

البخاري 405صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Prayer
Chapter
Scraping spit off the masjid with one's hand
Numbering
Darussalam 405
Bukhari 405