简体   繁体   中英

PHP mkdir(), chmod() and Windows

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

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

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

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM