PHP mkdir(), chmod() and Windows

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-27 08:11:43

问题


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:


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



回答2:


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?




回答3:


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



来源:https://stackoverflow.com/questions/739891/php-mkdir-chmod-and-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!