$imgextension= ".jpg";
$tmp = basename($PHP_SELF);
$tmp = preg_replace("/..{0,5}/",$imgextension,$tmp);
$dir = basename($PHP_SELF);
$dir = preg_replace("/..{0,5}/","",$tmp);
$location = "/" . $dir . "/" . $tmp;
Is this what you mean? This will return
/main/main.jpg
/history/history.jpg
depending on which program it's in.
C'mon, I'm sure you could have worked that out for yourself. Grin