Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

Newest file in folder.

Links for php scripts

Moderators: macek, egami, gesf

Newest file in folder.

Postby Patricko » Sat Sep 08, 2012 4:14 pm

Hi

So I'm trying to run website and I need a script which is showing the newest file in the folder.
Now I've got something like that:

Code: Select all
include <?php
if ($handle = opendir('../art/')) {
while (false !== ($file = readdir($handle))) {
if(is_file('../art/'.$file) && (($kiedy=filemtime('../art/'.$file))>$najnowszy)){
$najnowszy=$kiedy; $najnowszy_nazwa=$file;
}
}
closedir($handle);
}
echo 'Najowszy plik to: '.$najnowszy_nazwa.', bo z dnia: '.date ("M-d-Y G:i:s", $najnowszy);
include '$najnowszy';
?>


And on my website I can see the which file is the newest - but the file is not showing up - means include function doesn't work and I don't know why.

I'm new in php so I can't solve this problem on my own.

And I also don't know how to make this script to show the second newest file.

HELP PLX :D
Patricko
New php-forum User
New php-forum User
 
Posts: 1
Joined: Sat Sep 08, 2012 4:06 pm

Return to PHP Scripts

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron