예제 #1
0
 public function upload()
 {
     echo $target = create_uri($this->input->post('path'));
     if ($_FILES['file']['name'] != null) {
         $config['upload_path'] = DOC_ROOT . $target;
         $config['file_name'] = $this->input->post('name');
         $config['allowed_types'] = $this->input->post('allowed_types');
         $config['overwrite'] = TRUE;
         $this->load->library('upload', $config);
         if (!$this->upload->do_upload("file")) {
             $error = array('error' => $this->upload->display_errors());
             echo "<script type='text/javascript'>alert('gagal upload foto {$error['error']} !');history.go(-1)</script>";
         } else {
             echo "Profile picture berhasil diubah!";
             echo "<script>\n                setTimeout(function(){\n                    history.go(-1);\n                }, 2000)\n              </script>";
         }
     }
 }
예제 #2
0
 public function add()
 {
     $array = $this->input->post(NULL);
     $tags = $array['tags'];
     unset($array['tags']);
     if ($array['permalink'] != '') {
         $array['uri'] = 'permalink/' . $array['permalink'];
     } else {
         unset($array['permalink']);
     }
     $stat = $this->input->post('status') == 'Publish' ? 'published' : 'draft';
     $id = $this->mposts->add(array_merge($array, array('cover' => create_uri($array['cover']), 'thumbnail' => create_uri($array['thumbnail']), 'commentable' => $array['commentable'], 'user_id' => $this->session->userdata['user_id'], 'status' => $stat)));
     if ($tags != '') {
         $this->mtags->add($id, $tags);
     }
     redirect(base_url($array['uri']));
 }