php file path of server

Posted by Jacksta on Stack Overflow See other posts from Stack Overflow or by Jacksta
Published on 2010-04-15T08:33:47Z Indexed on 2010/04/15 8:43 UTC
Read the original article Hit count: 346

Filed under:
|

I am trying to get this script to work. it opens up a directry and lists the files in the directory. I have copied this code from somewhere else and the problem is that this php file is hosted on an apache server not my localhost. what is the correct $dir_name = "c:/"; to use?

The file is in this directory /domains/domainxxxx.com.au/public_html/lsitfiles.php so would I use domainxxxx.com.au/public_html/lsitfiles.php ?

<?php

$dir_name = "c:/";

$dir = opendir($dir_name);

$file_list = "<ul>";

while ($file_name = readdir($dir)) {
    if(($file_name != ".") && (file_name != "..")) {
    $file_list .= "<li>$file_name"; 
                               }
}

$file_list.= "<ul>";

closedir($dir);

?>

<HTML>
<BODY>

<p>Files in: <? echo "$dir_name"; ?></p>
<? echo "$file_list"; ?>


</BODY>
</HTML>

© Stack Overflow or respective owner

Related posts about php

Related posts about php5