Solved

List directory files in html table

Posted on 2004-03-26
2
398 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 250 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

734 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