i am trying to catch the relative path to a file to create a share link. From my httpdocs folder on the webserver, my file is here:
httpdocs
jack/single/uplo
You could use preg_replace on the output of realpath to replace everything up to httpdocs with your site's URL:
preg_replace
realpath
echo preg_replace('#^' . preg_quote($_SERVER['DOCUMENT_ROOT']) . '[\\\\/]#', "{$_SERVER['HTTP_HOST']}/", realpath('test6.php')) . "\n";