oubli
This commit is contained in:
parent
d88dac0546
commit
a74e7ae585
36
list-files.php
Normal file
36
list-files.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
function scanDirectory($dir = '.') {
|
||||
$files = [];
|
||||
$scan = scandir($dir);
|
||||
|
||||
foreach ($scan as $file) {
|
||||
// Ignore les fichiers cachés et les fichiers système
|
||||
if ($file[0] === '.' || in_array($file, ['index.html', 'list-files.php'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$path = $dir . '/' . $file;
|
||||
|
||||
if (is_file($path)) {
|
||||
$files[] = [
|
||||
'name' => $file,
|
||||
'size' => filesize($path),
|
||||
'date' => date('Y-m-d', filemtime($path)),
|
||||
'path' => rawurlencode($file)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
try {
|
||||
$files = scanDirectory('.');
|
||||
echo json_encode($files);
|
||||
} catch (Exception $e) {
|
||||
http_response_code(500);
|
||||
echo json_encode(['error' => $e->getMessage()]);
|
||||
}
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user