0
I need to make a web application that scans multiple directories, take the "last modified" and use the time to perform a SLA calculation to alert on the user screen.
I took a look at some code in PHP to scan directory and managed to do this below.
<?php
if ($dir[strlen($dir)-1] != '/') $dir .= '/';
if (!is_dir($dir)) return array();
$dir_objects = array();
while ($object = readdir($dir_handle)) {
if (!in_array($object, array('.','..'))) {
$filename = $dir.$object;
$file_object = array(
'name' => $object,
'size' => filesize($filename),
'type' => filetype($filename),
'time' => date("d/m/Y H:i:s", filemtime($filename))
);
$dir_objects[] = $file_object;
}
}
print_r($dir_objects);
?>
Note: I have a slight experience with PHP, so I’m asking for help. ^^'
Specify if the server is Windows or Linux, you can also check the PHP website for the stat function: https://php.net/manual/en/function.stat.php
– João Victor
Thanks for the help João!
– ramonfsk