★ wanayoo — archive 1999 http://www.php.net/manual/ja/function.mkdir.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to ファイルシステム
Quick Reference
English version of this pageGerman version of this pageItalian version of this pageFrench version of this pageHungarian version of this page
ファイルシステム
* basename
* chgrp
* chmod
* chown
* clearstatcache
* copy
* delete
* dirname
* diskfreespace
* fclose
* feof
* fgetc
* fgetcsv
* fgets
* fgetss
* file
* file_exists
* fileatime
* filectime
* filegroup
* fileinode
* filemtime
* fileowner
* fileperms
* filesize
* filetype
* flock
* fopen
* fpassthru
* fputs
* fread
* fscanf
* fseek
* fstat
* ftell
* ftruncate
* fwrite
* set_file_buffer
* is_dir
* is_executable
* is_file
* is_link
* is_readable
* is_writeable
* link
* linkinfo
* mkdir
* pclose
* popen
* readfile
* readlink
* rename
* rewind
* rmdir
* stat
* lstat
* realpath
* symlink
* tempnam
* touch
* umask
* unlink
Manual: mkdir
View the source code for this pageSearch the site



Previous page
 linkinfo
 Updated
Sat, 12 Aug 2000
pclose 
Next page


mkdir

(PHP3 , PHP4 )

mkdir -- ディレクトリを作る

説明

int mkdir (string pathname, int mode)

pathnameで指定されたディレクトリを 作成しようと試みます。

モードを8進数で指定する場合には、先頭にゼロを付ける必要が あることに注意して下さい。


mkdir ("/path/to/my/dir", 0700);
      

成功するとtrueを返し、失敗するとfalseを返します。

rmdir()も参照下さい。


User Contributed Notes: mkdir


aulbach@unter.franken.de
22-Jul-1999 02:37
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:

<PRE>
$oldumask = umask(0);
mkdir('mydir', 0777); // or even 01777 so you get the sticky bit set
umask($oldumask);
</PRE>



jeddings@jeddings.com
28-Sep-1999 05:26
With GNU's mkdir, you have the option (-p) of specifying whether or not to create intermediate parent directories if they do not exist (i.e. mkdir("/tmp/make/a/complex/path", 0700) will return an error if the path /tmp/make/a/complex does not exist). Is there any way (other than an exec) to do this with the mkdir() function?


theo@alldarlings.com
13-Jan-2000 11:53
I am using mkdir, and setting 0777, but when the directory is created, it is rwxrwxr-x, which would be 775. Any suggestions?

Thanks
-t



anton3@catalystinternet.com
15-Jan-2000 01:18
I had the same sort of problem, and couldn't figure out what was actually being set where, but this code actually works to get the directory permissions set to rwxrwxr-x:
<pre>
$oldumask = umask();
umask(002);
mkdir("$dirname",0777);
umask($oldumask);
</pre>


I'm not sure why it works, but I'll guess that umask(002) gets the umask set to 002 like I wanted, and having 777 on the mkdir means that you don't want to change the current umask.



rlynch@ignitionstate.com
11-Feb-2000 06:42
umask affects permissions when files and directories are created.

umask is short for "Un-Mask".

So "not" umask is "and"ed with the permissions of mkdir, fopen, etc.

In a sense, the umask setting is "subtracted" from the permissions given to mkdir.

Example:

<PRE>
umask(011);
mkdir('foo', 0777);
</PRE>
will actually make a directory with permissions 0766.



martin@digihosting.com
19-Mar-2000 04:18
Even though I create the new directory with 0777 I am not allowed to create files within it. If so, I get this error:

Warning: SAFE MODE Restriction in effect. The script whose uid is 533 is not allowed to access /dir/file.ext owned by uid 99

Are there any special mkdir commands to avoid this?



tricord@tricordnet.com
20-Apr-2000 09:45
I don't know how to solve this problem, but I know what causes it. A file or a dir chmod'ed to 0777 is seen as "unsecure" on some systems, because it has full read/write/execute permissions for everybody. Therefore access is blocked to most applications (including PHP3) to prevent a security hole.
Best thing is to use chmod 0775. If you create files with PHP, you can reopen them, delete them, write to them and execute them as you wish. 0777 is never a good idea, unless you really need it...



mbsrkch@soback.kornet21.net
01-Aug-2000 04:57
<pre>
I created several directories with usign
MKDIR on Sun Solaris. Here is the source:
&lt;?
$uploadDir1 = "./data/";
$stmt = "select count(*) from CA_ACCEPT";
$count_stmt=OCIParse($conn,$stmt);
OCIExecute($count_stmt);
OCIFetchInto($count_stmt,&$row);

$total_count = $row[0];

$total_attach ="/";
$total_count1 = $total_count.$total_attach;

$uploadDir = $uploadDir1.$total_count1;
echo("$uploadDir");

mkdir("$uploadDir",0777);
?>
Wnenever a user attach a file, The above
source will create automatically directory with the sequence number.

Hope that the source is pretty useful.




 About Notes


Previous page
 linkinfo
 Updated
Sat, 12 Aug 2000
pclose 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.