Photodynamic therapy is a new type of anti-tumor therapy with excellent therapeutic effects and minor side effects. The key factor for photodynamic therapy is highly efficient loading and protection of photosensitizers. Covalent organic framework is a new type of organic porous material with rich sources and has huge development potential in the loading of photosensitizers. However, the π-π interaction between the rigid monomers inevitably causes aggregation and quenching between photosensitizers, which in turn affects the rate of reactive oxygen production. Here, newly designed cationic flexible organic framework nanoparticles (PEI-Por NPs) are synthesized via one-step method with PEI25K and meso-tetra(p-formylphenyl)porphyrin under microwave irradiation. The structure of the flexible organic framework can effectively inhibit the aggregation and quenching of porphyrin. In addition, PEI-Por NPs had excellent gene transfection ability both in vitro and in vivo. Excellent antitumor effect can be achieved by combining PEI-Por NPs’ photodynamic therapy capacity and PEI-Por NPs-mediated PD-L1 gene silencing with the guidance of fluorescence imaging and photoacoustic imaging. This cationic flexible organic framework material combines the advantages of flexible building units and rigid monomers, which provides a basis for the development of nano-photosensitizers and excellent gene carriers, and has great potential for clinical application.