Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?PHP
- $directory="/web/magicmurals/prod/images/upload/";
- $sortOrder="newestFirst";
- $results = array();
- $handler = opendir($directory);
- echo "<h3>Custom Upload files</h3>";
- while ($file = readdir($handler)) {
- if ($file != '.' && $file != '..' && $file != "robots.txt" && $file != ".htaccess" && $file !='index.php'){
- $currentModified = filectime($directory."/".$file);
- $file_names[] = $file;
- $file_dates[] = $currentModified;
- }
- }
- closedir($handler);
- //Sort the date array by preferred order
- if ($sortOrder == "newestFirst"){
- arsort($file_dates);
- }else{
- asort($file_dates);
- }
- //Match file_names array to file_dates array
- $file_names_Array = array_keys($file_dates);
- foreach ($file_names_Array as $idx => $name) $name=$file_names[$name];
- $file_dates = array_merge($file_dates);
- $i = 0;
- //Loop through dates array and then echo the list
- foreach ($file_dates as $$file_dates){
- $date = $file_dates;
- $j = $file_names_Array[$i];
- $file = $file_names[$j];
- $i++;
- echo "<a href='$file' target='_blank'>$file</a><br>";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement