Imam Bukhari narrates: Qutaibah narrated to us the hadeeth, he said: Isma'eel bin Ja'far narrated to us the hadeeth, from Humaid, from Hazrat Anas (may Allāh be pleased with him), that
the Prophet ﷺ saw phlegm (in the direction) of the Qiblah. This was displeasing to him, until its effects appeared upon his face. He scraped that phlegm with his hand, then he said: When any one of you is in his prayer, he is conversing with his Rabb, or his Rabb is (turned) between him and the Qiblah, so let none of you spit towards the Qiblah, but let him spit towards his left side or under his feet. Then he took hold of a corner of his sheet and spat into it, then rubbed part of the spit upon another part, then he said: Or let him do it in this manner.
حَدَّثَنَا قُتَيْبَةُ، قَالَ حَدَّثَنَا إِسْمَاعِيلُ بْنُ جَعْفَرٍ، عَنْ حُمَيْدٍ، عَنْ أَنَسٍ، أَنَّ النَّبِيَّ صلى الله عليه وسلم رَأَى نُخَامَةً فِي الْقِبْلَةِ، فَشَقَّ ذَلِكَ عَلَيْهِ حَتَّى رُئِيَ فِي وَجْهِهِ، فَقَامَ فَحَكَّهُ بِيَدِهِ فَقَالَ " إِنَّ أَحَدَكُمْ إِذَا قَامَ فِي صَلاَتِهِ، فَإِنَّهُ يُنَاجِي رَبَّهُ ـ أَوْ إِنَّ رَبَّهُ بَيْنَهُ وَبَيْنَ الْقِبْلَةِ ـ فَلاَ يَبْزُقَنَّ أَحَدُكُمْ قِبَلَ قِبْلَتِهِ، وَلَكِنْ عَنْ يَسَارِهِ، أَوْ تَحْتَ قَدَمَيْهِ ". ثُمَّ أَخَذَ طَرَفَ رِدَائِهِ فَبَصَقَ فِيهِ، ثُمَّ رَدَّ بَعْضَهُ عَلَى بَعْضٍ، فَقَالَ " أَوْ يَفْعَلْ هَكَذَا ".
Reference: Sahih Al Bukhari 405