[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

List directory files in html table

Posted on 2004-03-26
2
Medium Priority
?
413 Views
Last Modified: 2008-02-01
I have a postgresql database with records that have files associated wich i intend to keep in a directory related to this record. Ex. record with id=1 will be in " var/www/html/1/ " .
What i want is to list all files related do the current record that are in the directory and give the oportunity to ther user to remove or make file upload.
0
Comment
Question by:mesonas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 2

Accepted Solution

by:
aabbas earned 1000 total points
ID: 10688179
Try the following and you will get a list of all the files in the selected directory.

<?php
// ... assuming that you already have the database connection and the ID value in $v
// following lines will read the filenames from the directory and list in a table.

if ($handle = opendir('/var/www/html/$v/.')) {
  echo "<table>";
    while (false !== ($file = readdir($handle))) {
        if ($file != "." && $file != "..") {
            echo "<tr><td>$file</td></tr>\n";
        }
    }
    closedir($handle);
  echo "</table>";
}
?>

Hope, it will help.

Best of luck.
0
 

Author Comment

by:mesonas
ID: 10688275
Just what I wanted ! Thanks !
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question