Advertisement
ssaidz

list.php show file list on folder

Nov 29th, 2023
612
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.56 KB | None | 0 0
  1.  
  2. <ul>
  3. <?php
  4.  
  5. $folder = 'uploads'; // Ganti dengan path folder yang diinginkan
  6.  
  7. $files = scandir($folder, SCANDIR_SORT_ASCENDING);
  8.  
  9. // Membalik urutan file
  10. $files = array_reverse($files);
  11.  
  12. // Menampilkan file sebagai link
  13. foreach ($files as $file) {
  14.     if (is_file($folder . '/' . $file)) {
  15.         $fileSizeMB = round(filesize($folder . '/' . $file) / (1024 * 1024), 2);
  16.         echo '[' . $fileSizeMB . 'MB] <a href="' . $folder . '/' . $file . '">' . $file . '</a> - ' . date("F d Y H:i:s.", filemtime($folder . '/' . $file)) . "<br>";
  17.     }
  18. }
  19. ?>
  20. </ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement