Why mkdir() function not working

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
egturnkey
Forum Commoner
Posts: 34
Joined: Sun Jul 26, 2009 7:35 pm

Why mkdir() function not working

Post by egturnkey »

Hello Dear Friend,

here i get that error

Code: Select all

 
Warning: mkdir() [function.mkdir]: No such file or directory in /hermes/web08/b1256/moo.faridaed/common/common.php on line 389
 


and here is the common.php code

Code: Select all

 
// create writable directory or change the chmod permission of chosen directory
function check_dir($dir) {
 
    if (!file_exists($dir)) {
         if (mkdir($dir, 0777))// create images dir
            $done = true;
 
    } else if (!is_writeable($dir)) {
        if (chmod($dir, 0777)) // change perm. setting
            $done = true;
 
    } else
        $done = true;
 
    return $done;
}
 


it should create a file where an images will goes
at following path products/images/
i've giveen /products/ and /images/ CHMOOD 777
and still getting the error :chomp:

thanks so much for helping me
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: Why mkdir() function not working

Post by Darhazer »

If you pass 'product/images' (or any subfolder) to mkdir, and 'product' (or all parent folders) does not exist, mkdir will fail, unless you do not use the recursive parameter:

Code: Select all

if (mkdir($dir, 0777, true))// create images dir
            $done = true;
egturnkey
Forum Commoner
Posts: 34
Joined: Sun Jul 26, 2009 7:35 pm

Re: Why mkdir() function not working

Post by egturnkey »

Darhazer wrote:If you pass 'product/images' (or any subfolder) to mkdir, and 'product' (or all parent folders) does not exist, mkdir will fail, unless you do not use the recursive parameter:

Code: Select all

if (mkdir($dir, 0777, true))// create images dir
            $done = true;
thanks, but product/images/ are do exist and i've give both 777
what is really hurts me that i've another account on same hosting and i do using same script and it works perfect !!

and both have same php.ini with safemode=off and register_global=On
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: Why mkdir() function not working

Post by Darhazer »

And what $dir actually contains?
egturnkey
Forum Commoner
Posts: 34
Joined: Sun Jul 26, 2009 7:35 pm

Re: Why mkdir() function not working

Post by egturnkey »

Darhazer wrote:And what $dir actually contains?
the function should create a dir and upload image to it, at /products/images/*
where * will be a number and so on
egturnkey
Forum Commoner
Posts: 34
Joined: Sun Jul 26, 2009 7:35 pm

Re: Why mkdir() function not working

Post by egturnkey »

thanks you7 guys, it has been solved

yes i don't know WHY ?? but as soon as i changed the Database with new one , it did works so this mean that the error was due to the database cause it should create a dir that has the same ID of the product i've added

hence it turn to be that i made an error in writting the database tables

thanks for you all for support

thread to be closed
Post Reply