php - Find FILE path relative to the htdocs directory -


i have script displays images present on folder. e.g. script path (from htdocs):

/admin/global/thisscript.php 

e.g. pictures folder path (from htdocs):

/public/test/images/ 

now need print under each image path of file starting htdocs directory. e.g. if have:

$picture1 = /web/mysite/htdocs/public/test/images/picture1.png $picture1name = basename($picture1) 

i'd print

print "/public/test/images/".$picture1name 

having

/public/test/images 

in variable automatically update if picture1.png path changes.

if use

$_server['php_self'] 

it returns path of file i'm displaing. also

__file__ __dir__ basename dirname 

are not working me.

how can path?

thank you

perhaps $_server['document_root']

edit:

something like:

$path = "/web/mysite/htdocs/public/test/images/picture1.png"; $path = dirname(str_replace($_server['document_root'], '', $path)); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -