Sunan Abi Dawud Book 2, Hadith 89
One day while the Messenger of Allah(ﷺ)was giving sermon he suddenly saw phlegm on the wall towards the qiblah(the direction to which Muslims turn in prayer) of the mosque. So he became angry at people. He then scraped it and sent for saffron and stained with it. He then said: When any one of you prays, Allah, the Exalted, faces him: he, therefore, should not spit before him.
The Messenger of Allah (ﷺ) said: When a man stands with the intention of saying prayer, or if any of you says prayer, he should not spit before him, nor at his right side; but he should do so at his left side, if there is a place for it; or he should spit under his left foot and then rub it off.
The Prophet(ﷺ) liked the twigs of the date-palm, and he often had one of them in his hand. He entered the mosque and saw phlegm in the wall towards qiblah and he scraped it. He then turned towards people in anger and said: Is any one of you is pleased to spit in his face? When any of you faces qiblah, he indeed faces his Lord, the Majestic the Glorious: the angels are at right side. Therefore, he should not spit on his right side or before him towards qiblah. He should spit towards his left side or beneath his foot. If he is in a hurry, he should do so-and-so. Describing it Ibn ‘Ajlan said: He should spit in his cloth and fold a part of it over the other.