j0sh1e
j0sh1e

Reputation: 296

php mkdir() not working properly

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

Upvotes: 0

Views: 102

Answers (3)

Visakh Vijayan
Visakh Vijayan

Reputation: 718

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");

Upvotes: 0

Works On Mine
Works On Mine

Reputation: 1121

Try This,

$path1 = "./".$w_type."/".$slugTitle; 

Upvotes: 1

zool
zool

Reputation: 106

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;

Upvotes: 0

Related Questions