Codeigniter -> File Upload Path | Folder Create
codeigniter, image-uploading, php
Solution
am not sure what they are talking about by using the file_exist function since you need to check if its the directory ..
$folderName = $this->model->functionName()->tableName;
$config['upload_path'] = "this/$folderName/";
if(!is_dir($folderName))
{
mkdir($folderName,0777);
}
please note that :
- i have added the permission to the folder so that you can upload files to it.
- i have removed the `else` since its not useful here ( as @mischa noted )..
Problem
Currently I have the following: `$config['upload_path'] = 'this/path/location/';` What I would like to do is create the following controller but I am not sure how to attack it!! ``` $data['folderName'] = $this->model->functionName()->tableName; $config['upload_path'] = 'this/'.$folderName.'/'; ``` How would I create the `$folderName?` dictionary on the sever? Jamie: Could I do the following? ``` if(!file_exists($folderName)) { $folder = mkdir('/location/'$folderName); return $folder; } else { $config['upload_path'] = $folder; } ```