Re: PHP mkdir with IIS and network share

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm not sure if you need the mode octal in the mkdir funcion in windows.
Anyway I hope you read a comment in the php's online mkdir function manual:

 mkdir will create directories with undesired/unexpected owner/group
settings in certain circumstandes when SAFE_MODE is on. See the bug report:
http://bugs.php.net/bug.php?id=24604

You might notice that when you create a new directory using this code:

mkdir($dir, 0777);

The created folder actually has permissions of 0755, instead of the
specified
0777. Why is this you ask? Because of umask(): http://www.php.net/umask

The default value of umask, at least on my setup, is 18. Which is 22 octal,
or
0022. This means that when you use mkdir() to CHMOD the created folder to
0777,
PHP takes 0777 and substracts the current value of umask, in our case 0022,
so
the result is 0755 - which is not what you wanted, probably.

The "fix" for this is simple, include this line:

$old_umask = umask(0);

Right before creating a folder with mkdir() to have the actual value you put
be
used as the CHMOD. If you would like to return umask to its original value
when
you're done, use this:

umask($old_umask);

"Dang Nguyen" <dang155@comcast.net> wrote in message
20031113035450.80265.qmail@pb1.pair.com">news:20031113035450.80265.qmail@pb1.pair.com...
> Hi All,
>
> I have a php script that was carried over from an Apache/Solaris
environment
> into a Windows 2000/IIS/PHP 4.3.4 environment.  Now I need to tweak the
> script a little to deal with the filesystem differences.  The script, as
> originally designed and written, can read files from the filesystem,
create
> directories, write files back to the filesystem, etc.  After moving to the
> Windows environment, the script is now required to access files on a
network
> share and create files and directories over the network share.  I've
figured
> out how to configure IIS so that PHP scripts will be able to read, using
> opendir(),readdir(), etc., from the network share.  However, after the
> reconfiguration of IIS, my scripts still cannot create directories over
the
> network share.  No errors are getting written to my error log file either.
>
> I have reconfigured IIS to use an account that has read and write
> permissions on the network share when "anonymous" access is used, which is
> how the scripts can now read and list files on the network share.   Does
> anyone have any other suggestions for me to check or do so that the
scripts
> can also create files and directories on the network share?
>
> code snippet:
> $directory = '\\\\seint16\\nt_share\\';
> mkdir($directory,0755);
>
>
> Thanks,
> Dang Nguyen

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux