Browse Source

adding

master
Björn 3 years ago
parent
commit
a80f5d72ee
2 changed files with 26 additions and 4 deletions
  1. +24
    -3
      app/FileManager.php
  2. +2
    -1
      resources/js/components/filemanager/filemanager.riot

+ 24
- 3
app/FileManager.php View File

@ -21,10 +21,14 @@ class FileManager
{ {
$results = []; $results = [];
$directories = [];
$files = [];
// getting files from directory // getting files from directory
$files = scandir($path);
$items = scandir($path);
foreach($files as $file) {
foreach($items as $file) {
// ignore parent directories // ignore parent directories
if ($file === '.' || $file === '..') { if ($file === '.' || $file === '..') {
@ -44,9 +48,26 @@ class FileManager
if ($result['is_file']) { if ($result['is_file']) {
$result['size'] = $this->formatBytes($meta['size']); $result['size'] = $this->formatBytes($meta['size']);
$files[] = $result;
} else {
$directories[] = $result;
} }
}
$results[] = $result;
usort($directories, function($a, $b) {
if (strtolower($a['filename']) < strtolower($b['filename'])) {
return 0;
} else {
return 1;
}
});
foreach($directories as $directory) {
$results[] = $directory;
}
foreach($files as $file) {
$results[] = $file;
} }
return $results; return $results;


+ 2
- 1
resources/js/components/filemanager/filemanager.riot View File

@ -72,7 +72,8 @@
/** /**
* *
*
*
*
*/ */
files() { files() {
axios.get('/api/file/' + this.props.id, { axios.get('/api/file/' + this.props.id, {


Loading…
Cancel
Save