예제 #1
0
파일: Ajax.php 프로젝트: piotrazsko/sushi
 public function action_upload()
 {
     $view = View::factory('/admin/category');
     $error_message = NULL;
     $filename = NULL;
     $name_category = Arr::get($_POST, 'nameCat', '');
     $chpu = Arr::get($_POST, 'chpu', '');
     $id = Arr::get($_POST, 'id', '');
     $category = new Model_Ajax();
     if ($this->request->method() == Request::POST) {
         if (isset($_FILES['imgupload'])) {
             $filename = $this->_save_image($_FILES['imgupload']);
             $category->create_category($filename, $name_category, $chpu, $id);
         }
     }
     if (!$filename) {
         $error_message = 'There was a problem while uploading the image.
             Make sure it is uploaded and must be JPG/PNG/GIF file.';
     }
     $this->redirect('/admin/category');
 }