The Messenger of Allah saw some sputum on the wall of the mosque. He picked up a stone and scraped it off, then he said, "If anyone of you needs to spit, he should not spit in fro not of him or to his right; let him spit to his right; let him spit to his left or under his left foot." (Using translation from Ibn Mājah 761)
أَنَّ أَبَا هُرَيْرَةَ وَأَبَا سَعِيدٍ الْخُدْرِيَّ أَخْبَرَاهُ أَنَّ رَسُولَ اللهِ ﷺ رَأَى نُخَامَةً فِي حَائِطِ الْمَسْجِدِ فَتَنَاوَلَ رَسُولُ اللهِ ﷺ حَصَاةً فَحَتَّهَا ثُمَّ قَالَ إِذَا تَنَخَّمَ أَحَدُكُمْ وَهُوَ يُصَلِّي فَلَا يَتَنَخَّمْ قِبَلَ وَجْهِهِ وَلَا عَنْ يَمِينِهِ وَلْيَبْصُقْ عَنْ يَسَارِهِ أَوْ تَحْتَ قَدَمِهِ الْيُسْرَى