All perfect praise be to Allaah, the Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His Slave and Messenger.
If the blood does not reach the stomach or the throat, the fast will be valid. If it reaches the stomach or the throat unintentionally, then fasting will still be valid according to the Hanbali and Shaafi‘i scholars. In Al-Mawsoo‘ah Al-Fiqhiyyah, it is stated,
The Hanafi and Maaliki scholars hold that if a person who suffers a nosebleed and blocks his nose until the blood came out of his mouth without reaching the throat, his/ her fast will still be valid, because the blood moved through the passage of the nose to the mouth without any of it being pushed to the stomach, and whatever does not reach the stomach does not break the fasting. However, swallowing blood from a nosebleed breaks fast. The words of Shaafi‘i and Hanbali scholars, however, imply that whatever reaches the stomach of the fasting person unintentionally does not break his/her fast.
And Allaah Knows best.