I am trying to make a script that will list all files in a directory created (or modified) on the date given in a $_GET request.
I have a script that lists all files and the dates but how.would I be able to 'order' them into a way where I can use my $_GET request. Knowing me it is something really simple, here is what I have already:
<?php putenv("TZ=Europe/London");
if ($handle = opendir('./Images/')) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
echo "$entry : " . date ("d/m/y", filemtime($entry))."<br />";
}
}
closedir($handle);
}
This will throw a stat error as it is looking for the filetime in the current directory.
Notice the filetime function contained the directory (filemtime($dir.$entry)
Try this
$dir = './Images'; // use a variable so you can easily use this again
if ($handle = opendir($dir)) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
if(filemtime($dir.$entry) == $_GET['date']) // set date paramter in the format of d/m/y
echo "$entry : " . date ("d/m/y", filemtime($dir.$entry))."<br />"; // notice './Images'
}
}
closedir($handle);
}
Here is the full PHP LIST FILES script from this page -
http://stackoverflow.com/questions/3062154/php-list-of-specific-files-in-a-directory/15678731#15678731
But, on line 135, instead of
echo $line;
Use this (change date to your desired)
if ( $new_array[$i][2] > strtotime('2013-03-19 17:14:40') ) {
echo $line;
}