Long-distance two-qubit coupling, mediated by a superconducting resonator, is a leading paradigm for performing entangling operations in a quantum computer based on spins in semiconducting materials. Here, we demonstrate a novel, controllable spin-photon coupling based on a longitudinal interaction between a spin qubit and a resonator. We show that coupling a singlet-triplet qubit to a high-impedance superconducting resonator can produce the desired longitudinal coupling when the qubit is driven near the resonators frequency. We measure the energy splitting of the qubit as a function of the drive amplitude and frequency of a microwave signal applied near the resonator antinode, revealing pronounced effects close to the resonator frequency due to longitudinal coupling. By tuning the amplitude of the drive, we reach a regime with longitudinal coupling exceeding $1$ MHz. This demonstrates a new mechanism for qubit-resonator coupling, and represents a stepping stone towards producing high-fidelity two-qubit gates mediated by a superconducting resonator.