Realization of a deterministic quantum Toffoli gate with a single photon