Jump to content

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


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...

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.