Jump to content

[SOLVED] Folder view works but can the output be formatted?


toxictoad

Recommended Posts

Hey all,

 

I want to use this script

<?php
$dir = "http://mysite.com/files/uploads/";

// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
            echo "filename: $file : filetype: " . filetype($dir . $file) . "\n";
        }
        closedir($dh);
    }
}

if ($handle = opendir('.')) {
    while (false !== ($file = readdir($handle))) {
        if ($file != "." && $file != "..") {
            echo "$file\n";
        }
    }
    closedir($handle);
}
?>

 

That works great but each file runs after the other and I'd prefer it if after each file there was a  <br /> but I haven't a clue where to start. Also I've seen on php.net ways to restrict what files are shown but again I don't know enough to modify what I have to do this. I'd like to hide .php files.

 

Can anyone help with this?

Thanks

any chance of an example? because I've added the <br /> before and after the /n in quotes and out of quotes. I've added the nl2br after the echo also with and without the <br /> and with and without the /n but I'm just not seeing what I need to do?

 

but I'm getting errors

 

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/mysite/public_html/files/uploads/index.php on line 8

Parse error: syntax error, unexpected '<' in /home/mysite/public_html/files/uploads/index.php on line 8

Parse error: syntax error, unexpected '"', expecting ',' or ';' in /home/mysite/public_html/files/uploads/index.php on line 8

 

 

Thanks...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.