Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In my web application I have the user sign up for an account, then the account data is saved in a mysql database. The user can then go to "index.php" and log in with their credentials. My application involves saving a file to a directory. So:

  1. User logs in.
  2. A table is displayed. The table contains a list of files saved in the directory that is for the individual user.
  3. The user uploads a file to their directory (by directory I mean like a folder).

How could I display the files in a folder in a table () using php?


share|improve this question

closed as off topic by John Conde Jul 16 '12 at 15:12

Questions on Webmasters Stack Exchange are expected to relate to webmastering within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

Tried migrating this to StackOverflow but it was automatically rejected. I don't know why. – John Conde Jul 16 '12 at 15:21
up vote 0 down vote accepted

Use glob() to loop through the directory and get the list of files in it.

foreach (glob("*.*") as $filename) {
  if (is_file($filename)) {
    echo "$filename size " . filesize($filename) . "\n";
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.