A new all-photonic switching of nonlinear optical materials with very low signal/noise background was presented. Fe and Mg were used to prepare doped and co-doped PbS/PVA freestanding nanocomposite; films were prepared by a simple chemical method with different doping concentrations. The X-ray diffraction patterns, scanning electron microscope images, and optical absorption spectrum of the prepared films were examined. The crystallinity and optical band gap of the prepared co-doped PbS/PVA were found to be affected by Fe and Mg, doping concentrations. The all prepared samples showed a blue shift in the absorption spectra and the optical band gap was increased when the doping concentration is increased. The all-optical switching effect performance of metal doped and (Fe, Mg) co-doped PbS/PVA with various Fe and Mg concentrations were investigated. The results showed that the (Fe, Mg) co-doped PbS/PVA at 1.2%M Fe and 0.8%M Mg doping concentration can demonstrate an active all-photonic switching device and lead to the realization with maximum modulation depth of 86.5% and switching contrast of 8.8 dB at minimum switching time of 47 ms.