Codeigniter -> File Upload Path | Folder Create
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 )..
This is not correct:
if(!file_exists($folderName)){ mkdir($folderName);}else{ // Carry on with upload}
Nothing will be uploaded if the folder does not exist! You have to get rid of the else clause.
$path = "this/$folderName/";if(!file_exists($path)){ mkdir($path);}// Carry on with upload$config['upload_path'] = $path;
Not quite sure what you mean by 'dictionary', but if you're asking about how to create a variable:
$folderName = $this->model->functionName()->tableName;$config['upload_path'] = "this/$folderName/";
To add/check the existence of a directory:
if(!file_exists($folderName)){ mkdir($folderName);}else{ // Carry on with upload}