Skip to content

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

@kaizenjinco

Description

@kaizenjinco

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions