-
Notifications
You must be signed in to change notification settings - Fork 292
Expand file tree
/
Copy pathfilelist.php
More file actions
32 lines (28 loc) · 1.01 KB
/
filelist.php
File metadata and controls
32 lines (28 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
if($_SESSION["IsLogin"] == false)
header('Location: login.php');
$files = scandir('uploads/');
$files = array_diff($files, array('.', '..'));
if(isset($_GET['sortby'])) {
$sortby = $_GET['sortby'];
if($sortby == 'name') {
sort($files);
} elseif($sortby == 'date') {
usort($files, function($a, $b) {
return filemtime('uploads/' . $a) < filemtime('uploads/' . $b);
});
}
}
foreach($files as $file) {
echo 'File Name: ' . $file . '<br>';
echo 'File Type: ' . mime_content_type('uploads/' . $file) . '<br>';
echo 'Upload Time: ' . date ("F d Y H:i:s.", filemtime('uploads/' . $file)) . '<br>';
echo 'File Size: ' . filesize('uploads/' . $file) . '<br><br>';
echo '<form action="delete.php" method="POST">
<input type="hidden" name="filename" value="' . $file . '">
<input type="submit" value="Delete">
</form>';
}
echo '<a href="?sortby=name">Sort by Name</a><br>';
echo '<a href="?sortby=date">Sort by Date</a><br>';
?>