jnejunior 1 Denunciar post Postado Fevereiro 7, 2011 falai pessoal... tem como no PHP fazer tipo o Windows Explorer, listar as pastas e subpastas de um diretorio como links? Compartilhar este post Link para o post Compartilhar em outros sites
Andrey Knupp Vital 136 Denunciar post Postado Fevereiro 7, 2011 Opa .. tem uma classe pronta aqui :seta: http://www.baixaki.com.br/download/simple-directory-listing.htm Compartilhar este post Link para o post Compartilhar em outros sites
jnejunior 1 Denunciar post Postado Fevereiro 7, 2011 Opa .. tem uma classe pronta aqui :seta: http://www.baixaki.com.br/download/simple-directory-listing.htm testei a classe mas não consegui fazer funcionar... alguem mais? Compartilhar este post Link para o post Compartilhar em outros sites
Andrey Knupp Vital 136 Denunciar post Postado Fevereiro 7, 2011 Qual erro ? Compartilhar este post Link para o post Compartilhar em outros sites
William Bruno 1501 Denunciar post Postado Fevereiro 7, 2011 tem sim, só saber html, e usar a função glob() por exemplo. qual a dúvida ? http://lmgtfy.com.br/?q=listar+diretorios+php Compartilhar este post Link para o post Compartilhar em outros sites
jnejunior 1 Denunciar post Postado Fevereiro 7, 2011 tem sim, só saber html, e usar a função glob() por exemplo. qual a dúvida ? http://lmgtfy.com.br/?q=listar+diretorios+php tipo assim: tenho um script que criei e ele lista os diretorios e arquivos da pasta que o index.php esta salvo, ou seja, htdocs... as pastas e arquivos são mostrados com sucesso, mas gostaria de mostrar as pastas e subpastas e seus arquivos respectivamentes para posteriormente usando JQuery criar um menu estilo Windows Explorer... entendeu? Compartilhar este post Link para o post Compartilhar em outros sites
William Bruno 1501 Denunciar post Postado Fevereiro 7, 2011 Sim, entendi. E qual a dificuldade? basta saber trabalhar com HTML.. criando subnivel com UL LI, numa estrutura hierárquica. Qual a dúvida? oque você não sabe fazer? Compartilhar este post Link para o post Compartilhar em outros sites
jnejunior 1 Denunciar post Postado Fevereiro 7, 2011 Sim, entendi. E qual a dificuldade? basta saber trabalhar com HTML.. criando subnivel com UL LI, numa estrutura hierárquica. Qual a dúvida? oque você não sabe fazer? eu preciso adaptar meu script para ele mostrar as sub-pastas e seus arquivos, o ul li é moleza... pode me ajudar? meu programa esta assim por enquanto... <?php function tamanho($arquivo) { $tamanho = filesize($arquivo); $kb = 1024; $mb = 1048576; $gb = 1073741824; $tb = 1099511627776; if ($tamanho < $kb) { return $tamanho . " bytes"; } elseif ($tamanho >= $kb && $tamanho < $mb) { $kilo = number_format($tamanho / $kb, 2); return $kilo . " KB"; } elseif ($tamanho >= $mb && $tamanho < $gb) { $mega = number_format($tamanho / $mb, 2); return $mega . " MB"; } elseif ($tamanho >= $gb && $tamanho < $tb) { $giga = number_format($tamanho / $gb, 2); return $giga . " GB"; } } function dataMod($arquivo) { $data = date("d.m.Y H:i:s", filemtime($arquivo)); return($data); } $arquivo = opendir('.'); echo '<table width="600"> <tr> <td>Descrição</td><td>Tamanho</td><td>Data de Modificação</td></tr>'; $dir = opendir('.'); $qtdArq = 0; $qtdDir = -2; while (false !== ($arq = readdir($dir))) { if (is_file($arq)) { $qtdArq++; } else { $qtdDir++; } } echo ' <tr><td> </td><td> </td><td> </td></tr> <tr class="info"><td> </td><td>Diretórios: ' . $qtdDir . '</td><td>Total: ' . ($qtdArq + $qtdDir) . '</td></tr> <tr class="info"><td> </td><td>Arquivos: ' . $qtdArq . '</td><td> </td></tr> <tr><td> </td><td> </td><td> </td></tr>'; while ($dir = readdir($arquivo)) { if ($dir != '..' && $dir != '.' && $dir != '') { if (is_dir($dir)) { echo '<tr><td><a href=' . $dir . '>' . '<img src="http://www.i-m-c.org/imc/images/folder-small.jpg" class="img" />' . $dir . '</a></td> <td>' . tamanho($dir) . '</td><td>' . dataMod($dir) . ' hs</td></tr>'; } elseif (is_file($dir)) { if (preg_match('/\.php$/', $dir)) { echo '<tr><td><a href=' . $dir . '>' . '<img src="http://www.mysticfrost.net/img/php_icon.png" />' . $dir . '</a></td> <td>' . tamanho($dir) . '</td><td>' . dataMod($dir) . ' hs</td></tr>'; } elseif (preg_match('/\.(txt|doc)$/', $dir)) { echo '<tr><td><a href=' . $dir . '>' . '<img src="http://www.baixamais.net/resources/banco-de-icones/documentos/doc-txt.gif" />' . $dir . '</a></td> <td>' . tamanho($dir) . '</td><td>' . dataMod($dir) . ' hs</td></tr>'; } elseif (preg_match('/\.(htm|html|xhtml)$/', $dir)) { echo '<tr><td><a href=' . $dir . '>' . '<img src="http://www.history.army.mil/images/HTML-globe.png" />' . $dir . '</a></td> <td>' . tamanho($dir) . '</td><td>' . dataMod($dir) . ' hs</td></tr>'; } else { echo '<tr><td><a href=' . $dir . '>' . '<img src="http://forum.joomlaworks.gr/Themes/JoomlaWorks/images/topic/veryhot_post.gif" />' . $dir . '</a></td> <td>' . tamanho($dir) . '</td><td>' . dataMod($dir) . ' hs</td></tr>'; } } } } echo '</table>'; closedir($arquivo); clearstatcache(); ?> Compartilhar este post Link para o post Compartilhar em outros sites
CARIN 0 Denunciar post Postado Fevereiro 23, 2017 Em 07/02/2011 at 21:47, jnejunior disse: alguem consegue modificar este codigo ai para que mostre os arquivos mais recentes primeiro na listagen do diretorio? <?php function tamanho($arquivo) { $tamanho = filesize($arquivo); $kb = 1024; $mb = 1048576; $gb = 1073741824; $tb = 1099511627776; if ($tamanho < $kb) { return $tamanho . " bytes"; } elseif ($tamanho >= $kb && $tamanho < $mb) { $kilo = number_format($tamanho / $kb, 2); return $kilo . " KB"; } elseif ($tamanho >= $mb && $tamanho < $gb) { $mega = number_format($tamanho / $mb, 2); return $mega . " MB"; } elseif ($tamanho >= $gb && $tamanho < $tb) { $giga = number_format($tamanho / $gb, 2); return $giga . " GB"; } } function dataMod($arquivo) { $data = date("d.m.Y H:i:s", filemtime($arquivo)); return($data); } $arquivo = opendir('.'); echo '<table width="600"> <tr> <td>Descrição</td><td>Tamanho</td><td>Data de Modificação</td></tr>'; $dir = opendir('.'); $qtdArq = 0; $qtdDir = -2; while (false !== ($arq = readdir($dir))) { if (is_file($arq)) { $qtdArq++; } else { $qtdDir++; } } echo ' <tr><td> </td><td> </td><td> </td></tr> <tr class="info"><td> </td><td>Diretórios: ' . $qtdDir . '</td><td>Total: ' . ($qtdArq + $qtdDir) . '</td></tr> <tr class="info"><td> </td><td>Arquivos: ' . $qtdArq . '</td><td> </td></tr> <tr><td> </td><td> </td><td> </td></tr>'; while ($dir = readdir($arquivo)) { if ($dir != '..' && $dir != '.' && $dir != '') { if (is_dir($dir)) { echo '<tr><td><a href=' . $dir . '>' . '<img src="http://www.i-m-c.org/imc/images/folder-small.jpg" class="img" />' . $dir . '</a></td> <td>' . tamanho($dir) . '</td><td>' . dataMod($dir) . ' hs</td></tr>'; } elseif (is_file($dir)) { if (preg_match('/\.php$/', $dir)) { echo '<tr><td><a href=' . $dir . '>' . '<img src="http://www.mysticfrost.net/img/php_icon.png" />' . $dir . '</a></td> <td>' . tamanho($dir) . '</td><td>' . dataMod($dir) . ' hs</td></tr>'; } elseif (preg_match('/\.(txt|doc)$/', $dir)) { echo '<tr><td><a href=' . $dir . '>' . '<img src="http://www.baixamais.net/resources/banco-de-icones/documentos/doc-txt.gif" />' . $dir . '</a></td> <td>' . tamanho($dir) . '</td><td>' . dataMod($dir) . ' hs</td></tr>'; } elseif (preg_match('/\.(htm|html|xhtml)$/', $dir)) { echo '<tr><td><a href=' . $dir . '>' . '<img src="http://www.history.army.mil/images/HTML-globe.png" />' . $dir . '</a></td> <td>' . tamanho($dir) . '</td><td>' . dataMod($dir) . ' hs</td></tr>'; } else { echo '<tr><td><a href=' . $dir . '>' . '<img src="http://forum.joomlaworks.gr/Themes/JoomlaWorks/images/topic/veryhot_post.gif" />' . $dir . '</a></td> <td>' . tamanho($dir) . '</td><td>' . dataMod($dir) . ' hs</td></tr>'; } } } } echo '</table>'; closedir($arquivo); clearstatcache(); ?> Compartilhar este post Link para o post Compartilhar em outros sites
CARIN 0 Denunciar post Postado Fevereiro 23, 2017 como eu posso retirar para que nao exibir o tamanho do arquivo? Compartilhar este post Link para o post Compartilhar em outros sites