Sunan Abi Dawud Book 2, Hadith 88
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 Messenger of Allah(ﷺ) said: if anyone enters the mosque, and spits in it, or ejects phlegm, he should remove some earth and bury it there. If he does not do so, then he should spit in his clothes and not come out with it.
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.