Get the directory name from a file path string in PHP
Key words and phrases
get file path from string php folder exists extract dirname filenameTags
Description
There is a built-in PHP function to get the directory portion of a file path from a string (lopping off the filename itself).

PHP Get file path