Codeigniter make directory if not exist
The date format wil have specail chars like -
and :
I'm not sure about the -
but :
is not allowed on an map. So you have to delete that char out $date
.
$date = str_replace( ':', '', $date);if (!is_dir('uploads/'.$date)) { mkdir('./uploads/' . $date, 0777, TRUE);}
or use as elavarasan lee said use:
date('Y-m-d H.i.s')
if(!is_dir($config['upload_path'])) mkdir($config['upload_path'], 0777, TRUE);
if you are new to codeigniter and previously in php you used code for making directory like
$target_dir="../../media/profile/".date('my')."/"; if(!file_exists($target_dir)){ mkdir($target_dir,0777); }
then in codeignitor you can use only one dot for outside directory path
$target_dir="././media/profile/".date('my')."/"; if(!file_exists($target_dir)){ mkdir($target_dir,0777); }
this one solved my problem.