Welcome Guest, Not a member yet? Register   Sign In
validation file uploadin
#1

Hello everybody
i am building a simple help system with codeigniter. and users can attachment files when response to a ticket.
But I do not know how to display error for users when uploading files has problem encountered in view tickets. please check my code. i really need your help Heart

PHP Code:
public function show()
 
   {
 
       $show = array();
 
       $id $this->uri->segment('3');
 
       $groups_id $this->ticket_model->get_groups_id($id);
 
       $show['show_ticket'] = $this->ticket_model->show($id$groups_id);

 
       foreach ($show['show_ticket'] as $show_value){
 
           $show_gorup_id $show_value['department_id'];
 
           $create_by_id $show_value['user_id'];
 
       }

 
       $show['show_ticket_comment'] = $this->ticket_model->get_reply($id);

 
       foreach ($this->aauth->get_user_groups() as $user_groups) {
 
           $user_groups_id $user_groups->id;
 
       }

 
       if (($this->aauth->is_member('Admin')) ||($user_groups_id == $show_gorup_id) || ($create_by_id == $this->aauth->get_user_id())) {
 
           $this->template->load('ticket/show_ticket'$show);
 
       }else{
 
           echo 'Access Denied';
 
       }
 
   








public function 
reply()
 
   {
 
       $config['upload_path'] = './file_ticket';
 
       $config['allowed_types'] = 'gif|jpg|png|jpeg|pdf|doc|docx|txt';
 
       $config['max_size'] = 4000;
 
       $config['max_width'] = 11024;
 
       $config['max_height'] = 7168;
 
       $this->load->library('upload'$config);
 
       $this->upload->initialize($config);

 
      // if ( !$this->upload->do_upload('userfile')) {
 
        //   $error = array('error' => $this->upload->display_errors());
 
         //  $this->load->view('upload_form', $error);
 
          // return;
 
       //}

 
       $uploadData $this->upload->data();
 
       $file $uploadData['file_name'];


 
       $this->form_validation->set_rules('comment''Comment''required|trim');
 
       if ($this->form_validation->run() == FALSE) {
 
        //    $this->template->load('ticket/show_ticket',array('groups' => $ticket_add));
 
       //what code needs for display error here ?

 
       } else {
 
           $reply_ticket['ticket_comment_id'] = '';
 
           $reply_ticket['ticket_id'] = $this->input->post('ticket_id');
 
           $reply_ticket['user_id'] = $this->aauth->get_user_id();
 
           $reply_ticket['comment'] = $this->input->post('comment');
 
           $reply_ticket['create_date'] = now();
 
           $reply_ticket['file'] = $file;
 
           $insert_ticket_comment $this->ticket_model->reply($reply_ticket);
 
           if ($insert_ticket_comment) {
 
               $show = array();
 
               $id $this->input->post('ticket_id');
 
               $groups_id $this->ticket_model->get_groups_id($id);
 
               $show['show_ticket'] = $this->ticket_model->show($id$groups_id);

 
               redirect('ticket/show/'.$id);
 
           }
 
       }
 
   
Reply


Messages In This Thread
validation file uploadin - by Ali - 05-05-2017, 12:17 AM
RE: validation file uploadin - by InsiteFX - 05-05-2017, 03:54 AM
RE: validation file uploadin - by Ali - 05-07-2017, 03:13 AM
RE: validation file uploadin - by arisroyo - 05-07-2017, 10:55 PM



Theme © iAndrew 2016 - Forum software by © MyBB