dongwenhui8900 2015-08-05 14:38 采纳率: 0%
浏览 109
已采纳

PHP mkdir函数在调用时返回错误

I am trying to create 3 folders based on the email address of a user. I have one main folder, then the folder named after the email address, and finally a folder named images or tracks or chains. I am passing the paths to a function which should create them. However, nothing is happening. Can you please tell me what I am doing wrong?

public function createFolder($email){
    $this->email=$email;
    $this->pictureDirectoryPath = "../Uploads/$this->email/images";
    $this->uploadedTracksPath = "../Uploads/$this->email/tracks";
    $this->chainsPath = "../Uploads/$this->email/chains";

    //Calling the function doIt(path) to create the acutal directory.
    //The desired path is passed as a parameter

     doIt($this->pictureDirectoryPath);
     doIt($this->uploadedTracksPath);
     doIt($this->chainsPath);

}

//Function doIt() which is supposed to create a directory 
//However, nothing happens when it is called..
public function doIt($path){
    if (!mkdir($path, 0777, true)) {
            die('Failed to create folders...');
        }
}
  • 写回答

1条回答 默认 最新

  • doulipi3742 2015-08-05 14:39
    关注

    To call functions/methods within a class you need to add $this-> or self:: depending on if it's static or not.

     $this->doIt($this->pictureDirectoryPath);
     $this->doIt($this->uploadedTracksPath);
     $this->doIt($this->chainsPath);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 pnpm 下载element-plus
  • ¥15 解决编写PyDracula时遇到的问题
  • ¥15 有没有人能解决下这个问题吗,本人不会编程
  • ¥15 plotBAPC画图出错
  • ¥30 关于#opencv#的问题:使用大疆无人机拍摄水稻田间图像,拼接成tif图片,用什么方法可以识别并框选出水稻作物行
  • ¥15 Python卡尔曼滤波融合
  • ¥20 iOS绕地区网络检测
  • ¥15 python验证码滑块图像识别
  • ¥15 根据背景及设计要求撰写设计报告
  • ¥20 能提供一下思路或者代码吗