[GH-ISSUE #1310] [Improvement] - Improve File and Directory Listing for UNC Paths #837

Open
opened 2026-03-02 16:01:43 +03:00 by kerem · 0 comments
Owner

Originally created by @kaizenjinco on GitHub (Apr 10, 2025).
Original GitHub issue: https://github.com/prasathmani/tinyfilemanager/issues/1310

Description:
I encountered an issue with listing files and directories when using a UNC path in the tinyfilemanager.php file of the Tiny File Manager. The current implementation at line 1326, which uses scandir, does not support UNC paths effectively. This results in the inability to list files and directories located on network shares.
$objects = is_readable($path) ? scandir($path) : array();

Proposed Improvement:
To address this issue, I suggest modifying the code from lines 1328 to 1340 to use a combination of opendir and readdir, which are more compatible with UNC paths. This approach has been tested and successfully lists files and directories from a UNC path.

Steps to Reproduce:

  1. Set $root_path to a UNC path, e.g., \\\\10.0.10.10\\Data.
  2. Attempt to list files and directories using the current implementation.
  3. Observe that files and directories are not listed.

Proposed Code Change:

$objects = [];

if (is_dir($path)) {
    if ($dh = opendir($path)) {
        while (($file = readdir($dh)) !== false) {
            if ($file !== '.' && $file !== '..') {
                $objects[] = $file;
            }
        }
        closedir($dh);
    }
}

Benefits:

  • Improved compatibility with network shares and UNC paths.
  • Enhanced functionality for users accessing files on network drives.

I hope this suggestion helps improve the functionality of the Tiny File Manager. Please let me know if further details or testing are needed.

Originally created by @kaizenjinco on GitHub (Apr 10, 2025). Original GitHub issue: https://github.com/prasathmani/tinyfilemanager/issues/1310 **Description:** I encountered an issue with listing files and directories when using a UNC path in the `tinyfilemanager.php` file of the Tiny File Manager. The current implementation at line 1326, which uses `scandir`, does not support UNC paths effectively. This results in the inability to list files and directories located on network shares. `$objects = is_readable($path) ? scandir($path) : array();` **Proposed Improvement:** To address this issue, I suggest modifying the code from lines 1328 to 1340 to use a combination of `opendir `and `readdir`, which are more compatible with UNC paths. This approach has been tested and successfully lists files and directories from a UNC path. **Steps to Reproduce:** 1. Set `$root_path` to a UNC path, e.g., `\\\\10.0.10.10\\Data`. 2. Attempt to list files and directories using the current implementation. 3. Observe that files and directories are not listed. **Proposed Code Change:** ```php $objects = []; if (is_dir($path)) { if ($dh = opendir($path)) { while (($file = readdir($dh)) !== false) { if ($file !== '.' && $file !== '..') { $objects[] = $file; } } closedir($dh); } } ``` **Benefits:** - Improved compatibility with network shares and UNC paths. - Enhanced functionality for users accessing files on network drives. I hope this suggestion helps improve the functionality of the Tiny File Manager. Please let me know if further details or testing are needed.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tinyfilemanager#837
No description provided.