The types of pollutants in water environment are very complex, so it is very important to develop a photocatalyst that can have universal applicability to a variety of pollutants. In this study, Bi4O5I2 was modified by Yb3+ and Er3+ doping, and an efficient photocatalyst with upconversion luminescence was found. After heat treatment, the sample was transformed from BiOI to Bi4O5I2 (BI), and the crystallite size of BI was significantly reduced and the porosity increased, which provided more active sites for the photocatalytic reaction, and the photocatalytic performance of BI samples was greatly improved. Compared with Er3+ single doped samples (BIE), Yb3+ and Er3+ co-doping (BIYE) effectively promotes the photogenerated carrier migration. Under simulated sunlight, BiOI, BI, BIE and BIYE degraded 30.1%, 62.2%, 72.6% and 92.1% of RhB solution within 30 min of illumination, respectively. In addition, the degradation of MB, MO, carmine, phenol and TC by BIYE were also tested. The results show that BIYE has a good ability to degrade a variety of organic pollutants that are difficult to degrade. The results of photocurrent response test show that BIYE has a stable photocurrent response signal to near-infrared light, which means that BIYE can respond to near-infrared light. The upconversion luminescence of the sample was further investigated. The energy transfer between Yb3+ and Er3+ enhances the upconversion luminescence of Er3+, that is, the conversion of near-infrared light into visible light, which can be absorbed and utilized by Bi4O5I2 matrix. The degradation of RhB solution was tested under near-infrared conditions, and the results show that BIYE also has excellent photocatalytic ability under near-infrared light.