Как вывести папки и файлы в таком продяке .. - директория назад ПАПКИ - директория папок всех друг за другом ФАЙЛЫ -директория файлов всех друг за другом
в даный момент у меня всё хаотично в разброс
Вот мой код
<table id="example2" class="table table-bordered table-hover dataTable" role="grid" aria-describedby="example2_info">
<thead>
<tr role="row">
<th class="sorting_asc" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Rendering engine: activate to sort column descending" aria-sort="ascending">Тип</th>
<th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">Название</th>
<th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Engine version: activate to sort column ascending">Дейтвие</th>
</tr>
</thead>
<tbody>
<div id="updateMe">
<?php
$dir = $_SERVER["DOCUMENT_ROOT"].$_SERVER['REQUEST_URI'];
// Открыть заведомо существующий каталог и начать считывать его содержимое
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
echo '<tr role="row" class="odd">';
if (filetype($dir . $file) == 'dir' && $file == '.' || $file == '..') {
echo '';
}
else if(filetype($dir . $file) == 'dir'){
echo '<td><i class="fa fa-folder"></i></td>';
echo '<td><a href="/backEnd/view/cms/pages/documents/'.$file.'">'.$file.'</a></td>';
echo '<td><a href="/backEnd/model/drive/delTree.php?dir='.$_SERVER['DOCUMENT_ROOT'].$_SERVER['REQUEST_URI'].$file.'&url='.$_SERVER['REQUEST_URI'].'" class="btn btn-danger">Удалить</a><button class="btn btn-default" type="button" id="rename" onClick="reply_click(this.value)" value="'.$file.'" data-toggle="modal" data-target="#modal-rename">Переименовать</button></td>
</tr>';
}
}
}
closedir($dh);
}
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
echo '<tr role="row" class="odd">';
if (filetype($dir . $file) == 'dir' && $file == '.' || $file == '..') {
echo '';
}
else if(filetype($dir . $file) == 'dir'){
echo '';
}
else {
$info = new SplFileInfo($file);
$spl = $info->getExtension();
if($spl == 'tiff' || $spl =='jpeg' || $spl =='bmp' || $spl =='jpe' || $spl =='jpg' || $spl =='png' || $spl =='gif' || $spl =='psd'){
echo '<td><i class="fa fa-file-image-o"></i></td>';
echo '<td><button id="zoomImg" type="button" onClick="zoom();" data-toggle="modal" data-target="#modal-zoom" value="/backEnd/view/cms/pages/documents/'.$file.'">'.$file.'</button></td>';
echo '<td><a href="/backEnd/model/drive/delTree.php?dir='.$_SERVER['DOCUMENT_ROOT'].$_SERVER['REQUEST_URI'].$file.'&url='.$_SERVER['REQUEST_URI'].'" class="btn btn-danger">Удалить</a><button class="btn btn-default" type="button" id="rename" onClick="reply_click(this.value)" value="'.$file.'" data-toggle="modal" data-target="#modal-rename">Переименовать</button></td>
</tr>';
}
else if($spl == 'docx' || $spl =='doc' || $spl =='dotx' || $spl =='dot' || $spl =='rtf' || $spl =='txt' || $spl =='pdf'){
echo '<td><i class="fa fa-file-word-o"></i></td>';
echo '<td><button id="zoomDoc" type="button" onClick="zoomDoc();" data-toggle="modal" data-target="#modal-zoom" value="/backEnd/view/cms/pages/documents/'.$file.'">'.$file.'</button></td>';
echo '<td><a href="/backEnd/model/drive/delTree.php?dir='.$_SERVER['DOCUMENT_ROOT'].$_SERVER['REQUEST_URI'].$file.'&url='.$_SERVER['REQUEST_URI'].'" class="btn btn-danger">Удалить</a><button class="btn btn-default" type="button" id="rename" onClick="reply_click(this.value)" value="'.$file.'" data-toggle="modal" data-target="#modal-rename">Переименовать</button></td>
</tr>';
}
else if($spl == 'xls' || $spl =='xlsx' || $spl =='ods' || $spl =='csv' || $spl =='exel'){
echo '<td><i class="fa fa-file-excel-o"></i></td>';
echo '<td><a href="/backEnd/view/cms/pages/documents/'.$file.'">'.$file.'</a></td>';
echo '<td><a href="/backEnd/model/drive/delTree.php?dir='.$_SERVER['DOCUMENT_ROOT'].$_SERVER['REQUEST_URI'].$file.'&url='.$_SERVER['REQUEST_URI'].'" class="btn btn-danger">Удалить</a><button class="btn btn-default" type="button" id="rename" onClick="reply_click(this.value)" value="'.$file.'" data-toggle="modal" data-target="#modal-rename">Переименовать</button></td>
</tr>';
}
else {
echo '';
}
}
}
}
closedir($dh);
}
?>
</div>
</tbody>
<tfoot>
<tr role="row">
<th class="sorting_asc" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Rendering engine: activate to sort column descending" aria-sort="ascending">Тип</th>
<th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">Название</th>
<th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Engine version: activate to sort column ascending">Дейтвие</th>
</tr>
</tfoot>
</table>
код рабочий покажет содержимое папок и файлов
Апостиль в Лос-Анджелесе без лишних нервов и бумажной волокиты
Основные этапы разработки сайта для стоматологической клиники
Продвижение своими сайтами как стратегия роста и независимости