Mkdir and subfolders

Hi, I can’t test this on the server, but if the folder date (Y) does not exist, this record will be created for the record. or do I need to do mkdir ("/ o_rec /". date (Y) first? Will all subfolders be supported if not present

if(!is_dir("/o_rec/" . date(Y) . "/" . date(m) . "/" . $id)) { mkdir("/o_rec/" . date(Y) . "/" . date(m) . "/" . $id); } 
+4
source share
2 answers

bool mkdir (string $ pathname [, int $ mode = 0777 [, bool $ recursive = false [, resource $ context]]])

you will need to set recursive to true

+18
source

You must use the "recursive" flag to call mkdir so that it does all the way you want.

http://php.net/manual/en/function.mkdir.php

Please note that a google search makes it look like an existing error, depending on your php version.

+1
source

All Articles