It is narrated from Sayyiduna Anas bin Malik (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) saw phlegm on the qiblah side of the mosque, so he scraped it off with his hand, and he (peace and blessings be upon him) said in anger: "When a servant stands and prays, he is speaking intimately with his Lord between himself and the qiblah. When one of you spits, let him spit to his left or under his feet, or do like this." Then he (peace and blessings be upon him) spat into his garment and rubbed it together. Yazid, the narrator, says: Humayd demonstrated it to us.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الطهارة / 1201