A simple photo-induced approach is developed for the preparation of COOH functionalized meso-macroporous carbon films with tunable pores without using any inorganic mesoporous silica templates, which show excellent sensing selectivity for aniline and the selectivity can be enhanced upon increasing COOH functional groups.