Authentication Services
Command Line Specific Extensions
Compression and Archive Extensions
Cryptography Extensions
Database Extensions
Date and Time Related Extensions
File System Related Extensions
Human Language and Character Encoding Support
Image Processing and Generation
Mail Related Extensions
Mathematical Extensions
Non-Text MIME Output
Process Control Extensions
Other Basic Extensions
Other Services
Search Engine Extensions
Server Specific Extensions
Session Extensions
Text Processing
Variable and Type Related Extensions
Web Services
Windows Only Extensions
XML Manipulation
GUI Extensions
Keyboard Shortcuts
?
This help
Next menu item
Previous menu item
Previous man page
Next man page
Scroll to bottom
Scroll to top
Goto homepage
Goto search
(current page)
Focus search box
mkdir
(
string
$directory
,
int
$permissions
= 0777
,
bool
$recursive
=
false
,
?
resource
$context
=
null
):
bool
尝试新建由
directory
指定的目录。
jack dot sleight at gmail dot com
¶
14 years ago
When using the recursive parameter bear in mind that if you're using chmod() after mkdir() to set the mode without it being modified by the value of uchar() you need to call chmod() on all created directories. ie:
<?php
mkdir
(
'/test1/test2'
,
0777
,
true
);
chmod
(
'/test1/test2'
,
0777
);
?>
May result in "/test1/test2" having a mode of 0777 but "/test1" still having a mode of 0755 from the mkdir() call. You'd need to do:
<?php
mkdir
(
'/test1/test2'
,
0777
,
true
);
chmod
(
'/test1'
,
0777
);
chmod
(
'/test1/test2'
,
0777
);
?>
aulbach at unter dot franken dot de
¶
25 years ago
This is an annotation from Stig Bakken:
The mode on your directory is affected by your current umask. It will end
up having (<mkdir-mode> and (not <umask>)). If you want to create one
that is publicly readable, do something like this:
<?php
$oldumask
=
umask
(
0
);
mkdir
(
'mydir'
,
0777
);
umask
(
$oldumask
);
?>
Protik Mukherjee
¶
19 years ago
mkdir, file rw, permission related notes for Fedora 3////
If you are using Fedora 3 and are facing permission problems, better check if SElinux is enabled on ur system. It add an additional layer of security and as a result PHP cant write to the folder eventhough it has 777 permissions. It took me almost a week to deal with this!
If you are not sure google for SElinux or 'disabling SELinux' and it may be the cure! Best of luck!
chelidze dot givia at gmail dot com
¶
1 year ago
When creating a file using mkdir() the default root will be the DocumentRoot (in XAMPP) itself.
C:\xampp\htdocs\project/includes/something.php
If you use mkdir("myfile") in something.php, instead of creating the folder in includes, php will create it in the project folder