I have a PHP program that has the user copying a URI into a text field. It then takes that text field and parses out the filename. The problem I'm having is if the user ju开发者_Go百科st puts "http://www.test.com/directory/" how can I tell if the file being served is index.php, index.html, etc etc? I tried using apache_lookup_uri, but it's not giving me the filename.
Thanks
You can't.
If the server is configured differently you can have files setup for directory index like main.html
jacko.asp
iphone4.jsp
Franky you only see on your end what parse_url gives you
<?php
$url = 'http://username:password@hostname/path?arg=value#anchor';
print_r(parse_url($url));
echo parse_url($url, PHP_URL_PATH);
?>
The above example will output:
Array
(
[scheme] => http
[host] => hostname
[user] => username
[pass] => password
[path] => /path
[query] => arg=value
[fragment] => anchor
)
/path
If they are on the same server you can look it up by hand in the conf files.
Or...
Create a dummy directory, having a dozen type of index files, each having as content their file name too. Make a request to the directory, and process the output. You have the server file name.
精彩评论