Jump to content

Display Content Of A Folder


TheyCallMeLuke

Recommended Posts

I've created a website that uploads files to a folder in the website.  I actually got my PHP script to work...kind of.  The script will display the contents of the folder just fine, but I also need the script to tell me the date and time it was modifed/uploaded.  Does anyone know what I can do to make this work?  I'm kinda a newbie at PHP, so this is probably much easier than I'm making it out to be.

Here is my code:

<?PHP
                 
        /** 
          *  Change  the  path  to  your  folder. 
          * 
          *  This  must  be  the  full  path  from  the  root  of  your 
          *  web  space.  If  you're  not  sure  what  it  is,  ask  your  host. 
          * 
          *  Name  this  file  index.php  and  place  in  the  directory. 
          */ 
                                                         
          //  Define  the  full  path  to  your  folder  from  root 
        $path  =  "UPLOADS/annualmeeting"; 
                                                         
          //  Open  the  folder 
        $dir_handle  =  @opendir($path)  or  die("Impossible  d'ouvrir  le  dossier  $path"); 
                                                         
        //  Loop  through  the  files 
        while  ($file  =  readdir($dir_handle))  { 
     
      if($file  ==  "."  ||  $file  ==  ".."  || is_dir($file) ||  $file  ==  "mm_menu.js"  ||  $file  ==  "index.php"  ||  substr($file,-3)  ==  "txt"  )
                                                         
        continue;
       
        $fichierexp  =  $path."/".$file.".txt";
        $TheLinkedFile  =  $path."/".$file;
        if(file_exists($fichierexp))  {
                @$fp  =  fopen($fichierexp,'r');
                echo  "<a  href=\"$TheLinkedFile\">".fgets($fp,999)."[/url]
";
                fclose($fp); 
            }  else  { 
                echo  "<a  href=\"$TheLinkedFile\">".$file."[/url]
"; 
            }
        }                                               
        //  Close 
        closedir($dir_handle);                                         
?>


It would be greatly appreciated if someone helped me out.  I'm suppose to have this finished by mid of next week. :'(
Link to comment
https://forums.phpfreaks.com/topic/35823-display-content-of-a-folder/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.