This question already has answers here:
How do I get a file name from a full path with PHP?
                                
                                    (15个答案)
                                
                        
                                6年前关闭。
            
                    
我将文件输入目录地址从kcfinder添加到html输入值中,如下所示:

/user/uploads/files/video/slider-bg2.jpg


现在,我只需要带有扩展名的文件名(例如:slider-bg2.jpg)即可插入MySQL数据库。如何从/user/uploads/files/images/删除或分离slider-bg2.jpg

最佳答案

你可以试试

SUBSTRING_INDEX("/user/uploads/files/video/slider-bg2.jpg","/",-1)


在MySQL中

所以

INSERT INTO table(columnname) values (SUBSTRING_INDEX("$yourFullFileNameWithDirectories","/",-1)

09-12 21:30