|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-01-11 12:23 UTC] losd at mail dot dk
Description:
------------
If the parent directory of a Windows network share is not accessible, you are still able to access subdirectories if given explicit permission.
However, PHP has trouble with the first accessible directory below an inaccessible directory. This is not a problem for the accessible dir's subdirs, though.
Scenario:
C:/Test/NoAccess/ -- Not accessible
Access/ -- Accesible from here
yyyyyyy.txt
Subdir/
xxxxxxx.txt
The problem has been found with opendir(), is_dir() and is_readable(). All directory functions are probably affected.
No workarounds has been found so far (suggestions appreciated).
Reproduce code:
---------------
<?php
if ($handle = opendir("C:/Test/NoAccess/Access/Subdir")) {
echo "Opened dir C:/Test/NoAccess/Access/Subdir<br/>";
while (false !== ($file = readdir($handle)))
echo"File: $file<br/>";
closedir($handle);
} else {
echo "Hmmmm, can't open directory, is it accessible?<br/>";
}
echo "<br/>";
if ($handle = opendir("C:/Test/NoAccess/Access")) {
echo "Opened directory C:/Test/NoAccess/Access<br/>";
while (false !== ($file = readdir($handle)))
echo"File: $file<br/>";
closedir($handle);
} else {
echo "Hmmmm, can't open directory, is it accessible?<br/>";
}
?>
Expected result:
----------------
Opened dir C:/Test/NoAccess/Access/Subdir
File: .
File: ..
File: xxxxxxx.txt
Opened dir C:/Test/NoAccess/Access
File: .
File: ..
File: yyyyyyy.txt
File: Subdir
Actual result:
--------------
Opened dir C:/Test/NoAccess/Access/Subdir
File: .
File: ..
File: xxxxxxx.txt
Warning: opendir(C:/Test/NoAccess/Access) [function.opendir]: failed to open dir: No such file or directory in C:\Inetpub\wwwroot\pm2\opendir.php on line 13
Hmmmm, can't open directory, is it accessible?
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 03:00:01 2025 UTC |
Temporary workaround found, but only if there is a known subdirectory inside the top accessible directory: opendir("C:/Test/NoAccess/Access/Subdir/..");Same problem with PHP 7.1.1 with Windows NT build 7601 (Windows 7 Ultimate Edition Service Pack 1) i586 It looks like chmod does not work either. I noticed that IIS does not have direct permission to access the file. Maybe to have access to the file, the direct editing is necessary. I used the Chmod ( chmod 777 ) for the file, but it was only applied in the directory, not being applicable to the files inside that directory. In my case, it was a case of file import by form (move_uploaded_file($tmp_name, $prev)). $prev = $dir. "/" .basename( $filename ); if(move_uploaded_file($tmp_name, $prev)){ echo "Success!". $prev } The file is copied but is not displayed in previews. The file does not have the permissions for the IIS_IUSRS user.