Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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?

thanks!

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

1 Answer 1

up vote 0 down vote accepted

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

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