The selective UV-vis absorption of spiropyran and the fluorescence quenching of SP-cellulose material induced by aniline were observed and exploited for rapid detection and accurate quantitative determination of aniline pollutants in the environment.