Foley was born in Heckscherville, Pennsylvania to Irish immigrants, Edward and Catherine McDonald Foley. At a young age he decided that he was not going to work the coal mines as his father had done. He joined the United States Marine Corps in 1888 for a period of five years. In 1893, he re-enlisted and, in 1898, he was sent to Cuba during the Spanish–American War where he received his first taste of military action. He also participated in the Philippines Campaign.