简体   繁体   English

PHP mkdir(),chmod()和Windows

[英]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). 我使用PHP函数mkdir($ path,0777)在Apache服务器上创建一个新目录(在Windows上运行)。

When I create this and view the folders, Windows has set the dir as read only. 当我创建它并查看文件夹时,Windows已将dir设置为只读。 Is there a way of changing this without using exec() to cacls.exe? 有没有办法改变这个而不使用exec()到cacls.exe? The PHP documentation states that chmod() doesn't work on Windows but doesn't say anything about a replacement method. PHP文档声明chmod()在Windows上不起作用,但没有说明替换方法。

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. 编辑:几分钟与我的两位教育机构的管理员交谈后,似乎他们为学生测试的PHP服务器正在运行USB驱动器。 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. (注意没有指定模式)在Win2K上适用于我 - 它创建一个没有设置属性的文件夹。

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); 我在php和cakephp中使用windows作为mkdir(“我的名字”,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). 根据PHP文档,在Windows上完全忽略mode参数(但默认为0777,因此无论如何都不必指定它)。 Try not specifying the mode at all and see what happens. 尽量不要指定模式,看看会发生什么。 Maybe it messes something up? 也许它搞砸了什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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