Sunan Ibn Majah, Book 4, Hadith 27 (In-Book)

It is narrated from Abu Hurairah and Abu Sa'eed Al-Khudri that: 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."

حَدَّثَنَا مُحَمَّدُ بْنُ عُثْمَانَ الْعُثْمَانِيُّ أَبُو مَرْوَانَ، حَدَّثَنَا إِبْرَاهِيمُ بْنُ سَعْدٍ، عَنِ ابْنِ شِهَابٍ، عَنْ حُمَيْدِ بْنِ عَبْدِ الرَّحْمَنِ بْنِ عَوْفٍ، عَنْ أَبِي هُرَيْرَةَ، وَأَبِي، سَعِيدٍ الْخُدْرِيِّ أَنَّهُمَا أَخْبَرَاهُ أَنَّ رَسُولَ اللَّهِ ـ صلى الله عليه وسلم ـ رَأَى نُخَامَةً فِي جِدَارِ الْمَسْجِدِ فَتَنَاوَلَ حَصَاةً فَحَكَّهَا ثُمَّ قَالَ ‏ "‏ إِذَا تَنَخَّمَ أَحَدُكُمْ فَلاَ يَتَنَخَّمَنَّ قِبَلَ وَجْهِهِ وَلاَ عَنْ يَمِينِهِ وَلْيَبْزُقْ عَنْ شِمَالِهِ أَوْ تَحْتَ قَدَمِهِ الْيُسْرَى ‏" ‏ ‏.‏

sunnah.com