It is narrated from Hazrat Abu Saeed (may Allah be pleased with him) that once the Prophet (peace and blessings be upon him) saw sputum or nasal discharge on the wall of the mosque. The Prophet (peace and blessings be upon him) cleaned it with a pebble and, forbidding spitting in front or to the right side, said that one should spit to the left side or under one's foot.
Hadith Referenceمسند احمد / مسند المكثرين من الصحابة / 11880
Hadith Gradingحکم دارالسلام:حديث صحيح، صالح- وهو ابن أبى الأخضر - وإن كان ضعيفا - قد توبع ، وانظر ما قبله