Link to home
Start Free TrialLog in
Avatar of jackie777
jackie777

asked on

PHP upload and list updater program

Hi,

Im a looking for some general (or specific) advice on how I can accomplish the following using php and mysql.

I want to give the user the ability to upload a pdf document to a file on the server. (I have this part figured out already using a php based upload form)

I want to have a web page that lists the pdfs that have been uploaded that directory in order by date 2007_01_12, 2006_06_04...ect

So I guess what I am wondering is how would I make it so the user simply uploads a document to the server. But, when the document gets uploaded, the php updates the web page that lists all the the documents in the upload directory listing a link to that newly uploaded document.

Is there a any to accomplish this without a database? Does anyone know where I could find some example code that does this?
Avatar of steelseth12
steelseth12
Flag of Cyprus image

<?


$d = dir("directory_path");

while (false !== ($entry = $d->read())) {
   
   if($entry != "." && $entry !="..") {
   
         $time = filectime($d->path.DIRECTORY_SEPARATOR.$entry);
         $files[$time]["name"][] = $entry ;
         $files[$time]["path"][] = $d->path.DIRECTORY_SEPARATOR.$entry ;
      }
}

$d->close();

krsort($files);


      foreach($files as $value) {
      
            if(count($value["name"]) > 1) {
            
                  for($i=0;$i<count($value["name"]);$i++) {
                  
                        print "<a href='".$value["path"][$i]."'>".$value["name"][$i]."</a><br>";
                  
                  }
            
            
            }else{
      
                  print "<a href='".$value["path"][0]."'>".$value["name"][0]."</a><br>";
            }
      
      }
?>
Avatar of jackie777
jackie777

ASKER

That worked perfectly, thanks.

Any idea what could do to limit the list that is displayed to 50? So that as new files are added, the old ones  no longer become available.
ASKER CERTIFIED SOLUTION
Avatar of steelseth12
steelseth12
Flag of Cyprus image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial