public function insertAction() { if (Jos::isPost()) { $params = Jos::getParams(); if ($this->_check($params)) { $objSlider = new Admin_Model_Slider(); // Check data input with data in database $check = $objSlider->checkInput($params['name']); if ($check > 0) { $this->view->errorName = "Name unable !!!"; } else { $dataInsert = array('name' => $params['name'], 'title' => $params['title'], 'status' => $params['status'], 'description' => $params['description'], 'rewrite' => $params['rewrite']); $objSlider->insertSlider($dataInsert); // Upload file if (isset($_FILES['image']['name']) && $_FILES['image']['name'] != null) { $data = $objSlider->getName($params['name']); // Get folder name $folder = $data['id']; $this->_upload($folder); $image = $_FILES['image']['name']; $dataUpdate = array('name' => $params['name'], 'title' => $params['title'], 'status' => $params['status'], 'description' => $params['description'], 'rewrite' => $params['rewrite'], 'images' => $image); $objSlider->updateSlider($dataUpdate, $folder); } redirect('admin/slider'); } } } $this->view->layout(); }