I'm experiencing a weird problem here, and maybe someone can shed some light on it.

I have the following code that fails on me with error Warning: mkdir(/home/jab/components/com_mos-chat/): No such file or directory:

if(!file_exists($this->componentDir()) && !mkdir($this->componentDir(),0777))
                {
                        $this->setError(1,"Failed to create directory'" . $this->componentDir() . "'");
                        return false;
                }

This is running on NetBSD/PHP 4.3.9. I have found that if I enclose the $this->componentDir() argument in quotes it works fine. The weird thing is that the same works on Linux or OS X box using the same PHP setup.
What am I missing? Thanks!

    1. check what user you're running as on the BSD box.

    2. try: mkdir -p

      Thanks for the reply!

      1. it is the root account...or www, I'll have to check.

      2. how do I make mkdir() function call up the -p switch?

      When I changed the magic_quotes_runtime to On in PHP ini, it seems to have worked, but it faild elsewhere..and it still doesn't explain why it works on other system with this setting set to Off.

        As for your second point, you could use the exec() function:

        if(exec("mkdir -p ".$base_dir.$sub_dir) && chmod($base_dir.$sub_dir, 0755)) {
            // do something 
        }
        

        Aside from that, you just need to do more investigating on what is different between the privilege levels assigned to your user on the BSD box as opposed to the other two OSes and your PHP setup.

          Write a Reply...