www.webdeveloper.com
Results 1 to 2 of 2

Thread: How do I generate a list of file names?

  1. #1
    Join Date
    May 2009
    Location
    Rochester, NY
    Posts
    372

    How do I generate a list of file names?

    I would like to display a list of files by name which reside in my FTP folders on a web page. How do I do this? I would preferably like the format to look like this:

    file001.jpg (20x14, 1104b)
    fieldGR.gif (100x200, 3002b)
    etc...

    If I can't get the image dimensions to show, that's ok. I just want to generate the list.

    Thanks.

  2. #2
    Join Date
    Nov 2008
    Posts
    2,477
    Untested and could do with some error checking but this should give you an idea.

    PHP Code:
    $imageExts = array('jpg''jpeg''gif');
    echo 
    '<ul>';
    foreach (
    glob('/path/to/files/*') as $file) {
        
    printf('<li>%s ('basename($file));
        if (
    in_array(pathinfo($filePATHINFO_EXTENSION), $imageExts)) {
            
    $size getimagesize($file);
            
    printf('%dx%d '$size[0], $size[1]);
        }
        
    printf('%sb)</li>'filesize($file));
    }
    echo 
    '</ul>'
    Last edited by Mindzai; 02-13-2010 at 04:58 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles