Hartley was awarded the VC for his action at Moirosi's Mountain, Basutoland on 5 June 1879. His citation from The London Gazette (issue 25023 of 7 October 1881) reads:
"On 5 June 1879 in South Africa, Surgeon Major Hartley attended the wounded under fire at the unsuccessful attack at Morosi's Mountain. From an exposed position, on open ground, he carried in his arms a wounded corporal of the Cape Mounted Riflemen. The surgeon major then returned under severe enemy fire in order to dress the wounds of the other men of the storming party."
He was later promoted to Surgeon-Colonel and served during the Second South African War. For his Boer War service he was created a Companion of the Order of St Michael and St George. He passed away at his home in Ash, Surrey.
Hartley's Victoria Cross and other medals are now displayed at the Army Medical Services Museum, Mytchett, Surrey.