A Guide to Mobile and Web Technology(LAMP)

This code will display all the files in the images folder.

foreach (glob("images/*.*") as $filename) {
       echo basename($filename);

Comments on: "List all the files in a directory in php" (3)

  1. Nice, this code is very useful when we can install a server on our friend’s machine and browse his computer without his knowledge!

    Hey, I think it will not list the files outside the site root folder (/usr/var/www/) right?

  2. It only works if the php resides in the same server.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: