Anas bin Malik reported,

The Prophet ﷺ saw some phlegm on the wall of the prayer direction and scraped it off with his hand. Displeasure was seen on his face, or rather his strong dislike of it was apparent, and he said, "When one of you stands in his prayer, he is conversing privately with his Lord, or his Lord is between him and his prayer direction. So let him not spit toward his prayer direction, but rather to his left or under his foot."Then he took the edge of his cloak, spat into it, and folded one part over the other. He said, "Or let him do like this."

Bukhari 417

Sahih

حدثنا مالك بن إسماعيل قال حدثنا زهير قال حدثنا حميد

عن أنس بن مالك

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

البخاري 417صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Prayer
Chapter
If spit comes out unexpectedly, let him catch it with the edge of his garment
Numbering
Darussalam 417
Bukhari 417