public function create()
{
$this->load->helper('form');
$this->load->library('form_validation');
$this->form_validation->set_rules('title', 'Başlık', 'trim|required');
$this->form_validation->set_rules('text', 'Yazı', 'trim|required');
$page="create";
if ($this->form_validation->run() === FALSE)
{
$this->show($page);
}
else
{
$title=$this->input->post('title');
$text=$this->input->post('text');
$date=$this->input->post('date');
$f=$this->input->post('file');
//$this->load->library("uploader");
if ($_FILES['dosya']['name'] != ""){
$this->uploadfile();
}else{
$message="added without file successfully";
$data['title']="Makale Listesi";
$data['list']=$this->makale_model->listing(0);
$data['page']=$page;
$data['message']=$message;
$this->show("modify",$data);
}
//$this->makale_model->insert($title,$text,$f,$date);
//$f=$data['']
}
}
private function uploadfile()
{
$config['upload_path'] = base_url().'/files/makaleler/';
$config['allowed_types'] = 'gif|jpg|png|bmp|jpeg|pdf|doc|docx|ppt|pptx';
//$config['max_size'] = '100';
//$config['max_width'] = '1024';
//$config['max_height'] = '768';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->show("create",$error);
}
else
{
$data = array('upload' => $this->upload->data());
$message="added successfully with file";
/*$data['title']="Listing";
$data['list']=$this->makale_model->listing(0);
$data['page']=$page;
$data['message']=$message;
$this->show("list",$data);
*/
$message=urlencode($message);
//redirect("makale/index?message=".$message,"refresh");
$this->show("modify",$data);
}
}