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 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?