2348

Codeigniter Tank Auth add folder upon registration

Question:

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; }

Answer1:

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);

Recommend

  • Why does the Trackbar value decrease on arrow up/PgUp?
  • Windows 7 - UAC - VB6 - Text File Can't Be “Seen” By Application
  • Start a process with elevated privilege [duplicate]
  • PowerShell execution policy subverted by powershell.exe parameter?
  • 500 internal server error in ruby on rails
  • LCD Programming with Arduino
  • Using HTML/CSS for UI in XNA?
  • You tube videos are not playing
  • Retrieve IP address of device
  • How can I tell a form not to dispose a particular control when it closes?
  • Hash Code in SQL Server?
  • Intel-64 and ia32 atomic operations acquire-release semantics and GCC 5+
  • Read text file that is not in the main package in a runnable jar
  • Web.config system.webserver errors
  • cygwin cannot exec 'git-add--interactive' permission denied
  • JBoss External Properties Files in Classpath
  • Not able to aggregate on nested fields in elasticsearch
  • htaccess add www if not subdomain, if subdomain remove www
  • How to set ini file attributes during an Inno install
  • Checking free space on FTP server
  • Change Inet root folder for iis 7
  • PHPUnit_Framework_TestCase class is not available. Fix… - Makegood , Eclipse
  • Jenkins: How To Build multiple projects from a TFS repository?
  • Sony Xperia Z Tablet not found by adb
  • Incrementing object id automatically JS constructor (static method and variable)
  • Javascript convert timezone issue
  • Updated Ionic CLI but shows previous version (Windows)
  • Why is the timeout on a windows udp receive socket always 500ms longer than set by SO_RCVTIMEO?
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent
  • Proper way to use connect-multiparty with express.js?
  • Free memory of cv::Mat loaded using FileStorage API
  • How do you join a server to an Active Directory (domain)?
  • unknown Exception android
  • MATLAB: Piecewise function in curve fitting toolbox using fittype
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • Binding checkboxes to object values in AngularJs
  • How can i traverse a binary tree from right to left in java?
  • How can I use `wmic` in a Windows PE script?
  • Conditional In-Line CSS for IE and Others?