Codeigniter Tank Auth add folder upon registration

独自空忆成欢 提交于 2019-12-25 05:03:59

问题


I have downloaded Tank Auth and am trying to create a folder when the user registers. I have edited the create_user() function in the users.php model like so but the folder does not get created. I am on Windows 7 so I thought maybe it was a permission thing. I turned off UAC, but it still does not work.

I want the folder to end up it the root directory where the index.php is (outside of application folder).

function create_user($data, $activated = TRUE)
    {
        $data['created'] = date('Y-m-d H:i:s');
        $data['activated'] = $activated ? 1 : 0;

        if ($this->db->insert($this->table_name, $data)) {
            $user_id = $this->db->insert_id();
            if(!is_dir("./uploads/".$user_id)){
                mkdir("./uploads/".$user_id , 0777);
            }

            if ($activated) $this->create_profile($user_id);
            return array('user_id' => $user_id);
        }
        return NULL;
    }

回答1:


Your problem is the directory is not relative to index.php - it needs to be absolute to index.php

Change

 if(!is_dir("./uploads/".$user_id)){
            mkdir("./uploads/".$user_id , 0777);

To

if(!is_dir(FCPATH.$user_id)){
            mkdir(FCPATH.$user_id , 0777);


来源:https://stackoverflow.com/questions/10905736/codeigniter-tank-auth-add-folder-upon-registration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!