views:

1980

answers:

3

Hello,

I am using the PHP function mkdir($path, 0777) to create a new directory on an Apache server (running on Windows).

When I create this and view the folders, Windows has set the dir as read only. Is there a way of changing this without using exec() to cacls.exe? The PHP documentation states that chmod() doesn't work on Windows but doesn't say anything about a replacement method.

Google seems to be a little unhelpful on this one.

EDIT: After several minutes talking to administrators at my two-bit educational institution, it seems that their test PHP server for students is being run off of a USB drive. I have a feeling that this will have something to do with it slaps head

+1  A: 

The following:

<?php
mkdir( "foo" )
?>

(note no mode specified) works for me on Win2K - it creates a folder with no attributes set.

Edit: Just had a thought - could it be something to do with permissions? Try running the above code from the command line & see what happens:

C:> c:\php\pgp.exe
    <?php
    mkdir( "foo" )
    ?>
    ^Z
anon
I'm on WinXP and it hasn't worked for me. It creates a dir called foo, but the read only tag is ticked (and greayed out too!)
Johnno
Also, I'm testing on PHP Version 5.2.4 on an Apache/2.2.0 (Win32) server. Unfortunately, I cannot change either of these.
Johnno
anon
The directory was made as usual, but the read only tag was greyed out and ticked still. I could easily go round unticking them, but this is for creation of a folder on user registrations so I'd be there all day!
Johnno
A: 

According to the PHP documentation, the mode parameter is completely ignored on Windows (but defaults to 0777, so you wouldn't have to specify it anyhow). Try not specifying the mode at all and see what happens. Maybe it messes something up?

Deniz Dogan
A: 

i am using in php and cakephp for windows as mkdir(" my dir name ",0777,true); it is working fine for me.

Mirza Zeeshan BAig