retrieving the most recent file uploaded to a directory
Posted: Wed Jan 28, 2009 8:41 am
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Hi
I'm using the code underneath to retrieve a list of files in a directory and display them as links on a webpage.
However, I just want to print the most recent file uploaded to that dir (ie there will be one uploaded every week and that is the only one i want to show)
Any ideas would be welcome!
thanks
Dee
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Hi
I'm using the code underneath to retrieve a list of files in a directory and display them as links on a webpage.
However, I just want to print the most recent file uploaded to that dir (ie there will be one uploaded every week and that is the only one i want to show)
Any ideas would be welcome!
thanks
Dee
Code: Select all
<?php
function DirDisply($data) {
$TrackDir=opendir("C:\\xampp\\htdocs\\anml\\EN\\Publications\\AnSceil\\");
while ($file = readdir($TrackDir)) {
if (strpos($file, '.pdf',1)||strpos($file, '.PDF',1)) {
if ($file == "." || $file == "..") { }
else {
print "<tr><td><font face=\"Verdana, Arial, Helvetica, sans-serif\"><a href=$file target=_blank>$file</a></font></td>";
print "</td></tr><br>";
}
}
}
closedir($TrackDir);
return $data;
}
?>
<b><font face="Verdana, Arial, Helvetica, sans-serif">An Scéil:</font></b>
<p>
<? @ DirDisply($data); ?>
</p>pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: