I can't seem to figure this out. I realize at this point that this just must be a simple syntax issue that is throwing me off, I'm fairly new to PHP so I am going to thank my noobiness for this one.
I am trying to create subdirectories ($slugTitle) within already existing directories ($w_type), yet the directories are failing to be created.
This is my code:
$path1 = "/".$w_type."/".$slugTitle;
$path2 = "/".$w_type."/".$slugTitle."/images";
$mode = 0777;
mkdir($path1);
mkdir($path2);
I've also tried:
$path1 = "/".$w_type."/".$slugTitle;
$path2 = "/".$w_type."/".$slugTitle."/images";
$mode = 0777;
mkdir($path1,$mode,TRUE);
mkdir($path2,$mode,TRUE);
and still now luck. Instead, I get directories that are named " instead of creating a directory within an already existing directory.
Please help! Thank you!
-Joshie
Try This,
$path1 = "./".$w_type."/".$slugTitle;
You try to add directiries to root directory
try to change
$path1 = "/".$w_type."/".$slugTitle;
to
$path1 = "/tmp/".$w_type."/".$slugTitle;
or to dirname (__FILE__) .$w_type."/".$slugTitle;
I have been having a tough time with mkdir() to get it to function in windows using CakePHP.
This doesn't work properly in windows
mkdir($this -> webroot . "uploads/abc");
Use this instead
mkdir(getCwd() . "/uploads/abc");