It is narrated from Sayyiduna Tariq bin Abdullah al-Muharibi (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) said: "When you are in prayer, do not ever spit to your right; rather spit behind you, or to your left, or under your left foot."
This is the narration of Bundar.
And Abu Musa said (in his narration): "(Sufyan) said: Mansur narrated to me," and he also said: "(Tariq) said: the Messenger of Allah (peace and blessings be upon him) said to me," and he said: "Spit behind you or to your left, if that place is empty, otherwise (spit) like this, under your left foot."
Related hadith on this topic