A search for flavour-changing neutral current (FCNC) events via the coupling of a top quark, a photon, and an up or charm quark is presented using 81 fb−1 of proton–proton collision data taken at a centre-of-mass energy of 13 TeV with the ATLAS detector at the LHC. Events with a photon, an electron or muon, a b-tagged jet, and missing transverse momentum are selected. A neural network based on kinematic variables differentiates between events from signal and background processes. The data are consistent with the background-only hypothesis, and limits are set on the strength of the tqγ coupling in an effective field theory. These are also interpreted as 95% CL upper limits on the cross section for FCNC tγ production via a left-handed (right-handed) tuγ coupling of 36 fb (78 fb) and on the branching ratio for t→γu of 2.8 x 10-5 ( 6.1 x 10-5). In addition, they are interpreted as 95% CL upper limits on the cross section for FCNC tγ production via a left-handed (right-handed) tcγ coupling of 40 fb (33 fb) and on the branching ratio for t→γc of 22 x 10-5 ( 18 x 10-5).