|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-01-19 01:00 UTC] coyle at washpenn dot com
Description:
------------
Using UNC path to save out a file in PHP 5.1.6 and everything works great. Upgraded to PHP 5.2.0 today and the UNC will not work anymore.
Reproduce code:
---------------
$path = '\\\\server\\share\\directory\\'
if(is_dir($path)) {
print 'directory exists';
} else {
print 'directory does not exists';
}
Expected result:
----------------
directory exists
Actual result:
--------------
directory does not exists
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 14:00:01 2025 UTC |
Above: $path = '\\server\share\directory'; Should be: $path = '\\\\server\share\directory'; I am running out of things to try here. When I print $path, I get a valid UNC path with no spaces anywhere but I still get the error above.PHP 5.3.3, windows 2008 R2, IIS 7.5. This simple page: <?php $path = '\\\\server\\share\\'; $f = fopen($path . "somefile.txt", "w") or die ("can't open"); fwrite($f,"AAAAA"); print 'wroted-----'; fclose($f); if(is_dir($path)) { print 'directory' . $path . 'exists'; } else { print 'directory' . $path . ' does not exists'; } ?> return me PHP Warning: fopen(\\server\share\somefile.txt) [function.fopen]: failed to open stream: Invalid argument in C:\xxx\xxx\moodle\testdir.php on line 4 If I comment the write function I obtain : directory\\server\share\ does not existsHere the SO as showed by phpinfo : Windows NT W-WEB01 6.1 build 7600 (Unknow Windows version Standard Edition) i586 it's a Windows 2008 R2 Standard IIS application pool runs with a domain administrator account. Share runs on another server, W2003 STD, everyone users has full rights on both share permission and physical folder permission. With this test page named testdir.php: <?php $path = '\\\\ett2\\tempdb\\'; $f = fopen($path . "somefile.txt", "w") or die ("can't open"); fwrite($f,"AAAAA"); print 'wroted-----'; fclose($f); if(is_dir($path)) { print 'directory' . $path . 'exists'; } else { print 'directory' . $path . ' does not exists'; } ?> I obtain "can't open" on the web page and this message on the event log: The description for Event ID 2 from source PHP-5.3.4RC1 cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer. If the event originated on another computer, the display information had to be saved with the event. The following information was included with the event: php[3852] PHP Warning: fopen(\\ett2\tempdb\somefile.txt) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: Invalid argument in [sitephysicalpath]\testdir.php on line 5 Let me know if you need more information or if i could help with more test. Regards, GianlucaI cannot replicate this bug. Using the following script under IIS (with and without fastcgi.impersonate), under Apache2.2, and via CLI, all with recommended INI settings for both 5.3.4RC2 and 5.2.15RC2, I get expected output: <?php $share = '\\\\win7-share-af04\\share'; echo 'current user: '; var_dump( get_current_user() ); echo '---TEST-ONE---'."\n"; $targets = array( 'exists' =>'test_folder', 'missing'=>'not_here', 'file'=>'foo.txt', ); foreach( $targets as $name => $target ) { echo $name."\n"; $path = $share . DIRECTORY_SEPARATOR . $target; echo ' path: '; var_dump( $path ); echo ' is_dir: '; var_dump( is_dir( $path ) ); } echo '---TEST-TWO---'."\n"; $bartxt = fopen( ( $share . DIRECTORY_SEPARATOR . 'bar.txt' ), "w" ) or false; if( !$bartxt ) { echo 'failed to open stream'; } else { fwrite( $bartxt, 'FUBAR '.time() ); fclose( $bartxt ); echo 'wrote file.'; }?> Example result (IIS with impersonation): ---TEST-ONE--- exists path: string(43) "\\win7-share-af04\share\test_folder" is_dir: bool(true) missing path: string(40) "\\win7-share-af04\share\not_here" is_dir: bool(false) file path: string(39) "\\win7-share-af04\share\foo.txt" is_dir: bool(false) ---TEST-TWO--- wrote file. The file is created properly and is_dir reports accurately in all scenarios, except that which I don't have permission to see the share or the share is inaccessible. Have you tried using procmon to see the request for the file and the filesystem's response?