SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Feb 2010
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Identifying if file is a directory

    I am building a local filing system on my localhost.

    I can display all of the files and can link to the files, but I want to identify if a file is a directory so I can apply a special link to it. SO...


    PHP Code:
     <?php

    $dir 
    "something/afolder/"

    $filenamejj $dirArray[$index];
        
    $isdir is_dir($dir);
            if(
    $isdir) {
            
    $ext end(explode('.'$filenamejj));
            print(
    "<TR><TD><a href='filer.php?dir=$dir/$filenamejj'>$dirArray[$index]</a></td><td>Directory</td>");
            } else {
            
    $ext end(explode('.'$filenamejj));
            print(
    "<TR><TD><a href='openfile.php?$dir/$filenamejj'>$dirArray[$index]</a></td><td>$ext</td>");
            }
            
            print(
    "</TR>\n");
    This is just a snippet which is the conditional statement to decide whether it is a directory or not. For some reason, it always says that the files are not directories, even when I know when one isn't.

    If anyone could help me that would be great thanks!

    Jordan

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    First of all, what does file_exists($dir) come up with?
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona


Tags for this Thread

Bookmarks

Posting Permissions

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