از این کد برای حذف نام و پسوند فایل از مسیر استفاده کنید:

$s = '/dirname/subdir/filename.txt';
 
$dirname = strrev(strstr(strrev($s),'/'));