我是Codeigniter的新手。 我有一个问题,正在寻求帮助。 我想在将数据输入到具有目录名称的数据库时创建目录,该目录名称来自创建数据库时的数组。如果我创建一个具有特定名称的目录,它可以工作。
public function insert()
{
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<div class="error">', '</div>');
$this->form_validation->set_rules('dname', 'Name', 'required|min_length[5]|max_length[50]');
$this->form_validation->set_rules('ddate', 'Date', 'required|date_valid');
if ($this->form_validation->run() == FALSE){
$this->loading_content('admin/new_event');
} else {
$panggil = array(
'name' => $this->input->post('dname'),
'event_date' => $this->input->post('ddate')
);
$path ="./lainnya/img/event/".$data->name."/";
mkdir($path, 0777); --> THIS CODE NOT WORKING
// mkdir("lainnya/img/event/okdeh",0777); --> THIS CODE IS WORKING
$this->m_event->form_insert($panggil);
$data['message'] = 'Data Inserted Successfully';
$this->loading_content('admin/event', $panggil);
}
}
感谢您的帮助。
我已经找到了答案...也许外面有人需要它。
public function insert()
{
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<div class="error">', '</div>');
$this->form_validation->set_rules('dname', 'Name', 'required|min_length[5]|max_length[50]');
$this->form_validation->set_rules('ddate', 'Date', 'required|date_valid');
if ($this->form_validation->run() == FALSE){
$this->loading_content('admin/new_event');
} else {
$panggil = array(
'name' => $this->input->post('dname'),
'event_date' => $this->input->post('ddate')
);
//$path ="./lainnya/img/event/".$panggil->'name'."/"; ---> **BEFORE**
$path ="./lainnya/img/event/".$panggil->['name']."/"; -- **NOW**
mkdir($path, 0777);
$this->m_event->form_insert($panggil);
$data['message'] = 'Data Inserted Successfully';
$this->loading_content('admin/event', $panggil);
}
}