The authors describe an aptamer based method for the determination of the antibiotic sulfadimethoxine (SLF). It is making use of upconversion nanoparticles (UCNPs) that act as an internal fluorophors signals, and of aptamers that can specifically recognize SLF. The UCNPs were deposited on the surface of magnetic nanoparticles (magNPs) functionalized with the aptamer. In the presence of SLF, parts of the UCNPs dissociate from the surface of the magNPs, and this results in decreased fluorescence intensity. The findings were exploited to design a fluorometric assay for SLF that has a 0.11 ng·mL−1 detection limit. The method was successfully applied to the quantification of SLF in spiked samples of perch and catfish. Recoveries range from 80.3% to 92.7%, and RSDs from 2.4% to 3.6%.