?
Solved

List directory files in html table

Posted on 2004-03-26
2
Medium Priority
?
407 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

770 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