Jump to content

file system for PHP


termanater13
 Share

Recommended Posts

I have XAMPP on my computer and I want to edit the index file to show all the folders in the local host directory, so I could surf all the web pages I have saved in the local host folder, and I do not want to do anything with MySql with this.I'm asking since I can only find a reference page, Im not asking for people to make the code for me, I just want help so I can mek it my self.

Link to comment
Share on other sites

thanks, I figured out what I need to edit in it to get what I want done, thanks for the helpthe code below is edited code from the site msd gave and im getting a "Parse error: syntax error, unexpected T_ELSEIF in C:\Program Files\xampplite\htdocs\test.php on line 15"
<?phpecho '<html>';echo '<head>';echo '<title>Local Host DIR</title>';echo '</head>';echo '<body>';echo '<table align="center" width="50%">';if ($handle = opendir('.')) {    while (false !== ($file = readdir($handle))) {        if ($file != "." && $file != "..") {            echo "<tr>";	        echo "<td align=\"center\">" . "<a href=\"$file\">$file</a>" . "</td>" . "\n";            if(is_dir($file)) {              echo "<td align=\"center\">directory</td>";            elseif (is_executable($file))              echo "<td align=\"center\">executable</td>";            elseif (is_file($file))              echo "<td align=\"center\">regular file</td>";            else              echo "<td align=\"center\">unknown to PHP</td>";            }	        echo "</tr>";                  }    }    closedir($handle);}echo '</tr>';echo '</table>';echo '</body>';echo '<html>';?> 

Link to comment
Share on other sites

IF goes like this:

if (condition) {   do something}elseif (other condition){   do something else}else {   do something else 2}

You problem is here:

if(is_dir($file)) {echo "<td align=\"center\">directory</td>";elseif (is_executable($file))

You wrote: if (condition){ elseif {do something}. WRONG.Delete { from line 15 and } from line 21.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...