How can I get just the filename of the originating document?
How can I get just the filename of the originating document?
$ref=@$_SERVER[HTTP_REFERER]; gives me the full http path
$ref=@$_SERVER[REQUEST_URI]; gives me the /directoryname/filename
I only want the filename. Nothing else.
Can you help?
Thanks
Sas
PHP
Last Comment
Dave Baldwin
8/22/2022 - Mon
Dave Baldwin
On many servers, 'SCRIPT_NAME' gives you just the filename. However, this is not guaranteed. Each server and admin may provide a different set of values because they all come from the server.
I use this program to see what my servers provide.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><title>PHP Server Variables</title></head><body><h1>PHP Server Variables</h1><?php//reset($_SERVER);foreach($_SERVER as $key => $value) { echo "<b>$key :</b> $value<br />\n";}?></body></html>
Thanks for your quick response Dave,
Your list gives me a lot of information that I'm not looking for.
And it doesn't give me the simple, isolated filename that I am looking for.
I just want the 'filename' not its directory, not its path.
Can you isolate the 'filename'?
Sas
http://php.net/manual/en/reserved.variables.server.php
I use this program to see what my servers provide.
Open in new window