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);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向