Comunque per lavorare con i path dei file c'e' una funzione apposta: http://php.net/pathinfo