Use strpos and pathinfo to check and remove file extension