php - Code Igniter : Ajax POST show 500 Internal Error -


i new codeigniter, uploading images , posting input fields database using ajax, jquery, , code igniter , throwing error 500 internal error.

i have multiple input fields generated dynamically user has 5 text fields , 1 file input field.

i want upload multiple images store names of images database.

 function showrows(){     var randomuniqueno = new date().getutcmilliseconds();     var length = $('#noofrow').val();     var element = "<tr><th style='width:10%'>code</th><th style='width:10%'>day</th><th style='width:10%'>time</th><th style='width:15%'>location</th><th style='width:20%'>image</th><th style='width:25%'>description</th></tr>";     for(var =0; i<length; i++){       element += '<tr><td><input type="text" readonly class="form-control" id="iti_code[]" value="iti'+randomuniqueno+'" name="iti_code[]"></td><td><input type="text" class="form-control" id="iti_day[]" value="" name="iti_day[]"></td><td><input type="text" class="form-control" id="iti_time[]" value="" name="iti_time[]"></td><td><input type="text" class="form-control" id="iti_loc[]" value="" name="iti_loc[]"></td><td><input type="file" class="form-control" id="iti_image[]" value="" name="iti_image[]"></td><td><textarea class="form-control" name="iti_desc[]" id="iti_desc[]"></textarea></td></tr>';     }     $('#showrows').html(element);   } 

below code.

jquery

$(function(){ $("#itiadd").submit(function(e){       e.preventdefault();       $.ajax({         type: "post",         url: '<?php echo base_url() ?>index.php/packagesmanagement/additinerary',         data: $("#itiadd").serializearray(),         success:function(data)         {           console.log(data);           $('#tp_iti').val(data);           $('#additi').modal('hide');           $('#btn-iti').text('edit itinerary');         },         error: function (xhr, status, response) {           console.log(status+' --- '+' --- ' + response);         }       });     }); }); 

controller

public function additinerary(){         if ($this->input->post('iti_code')) {             $code_send = " ";             $iti_code = $this->input->post('iti_code', true);             $iti_day = $this->input->post('iti_day', true);             $iti_time = $this->input->post('iti_time', true);             $iti_loc = $this->input->post('iti_loc', true);             $iti_desc = $this->input->post('iti_desc', true);             $config = array(                 'upload_path' => './uploadedimages/',                 'allowed_types' => 'gif|jpg|png',             );             $name_array = array();             $files = $_files;             $cpt = count($_files['iti_image']['name']);             for($i=0; $i<=$cpt-1; $i++)             {                              $this->load->library('upload', $config);                 $data = $this->upload->do_upload('iti_image');                 $name_array[] = $this->upload->data('file_name');             }                foreach ($iti_code $i => $a) {                  $data = array(                     'iti_code' => isset($iti_code[$i]) ? $iti_code[$i] : '',                     'iti_day' => isset($iti_day[$i]) ? $iti_day[$i] : '',                     'iti_time' => isset($iti_time[$i]) ? $iti_time[$i] : '',                     'iti_loc' => isset($iti_loc[$i]) ? $iti_loc[$i] : '',                     'iti_desc' => isset($iti_desc[$i]) ? $iti_desc[$i] : '',                     'iti_image' =>$name_array[$i],                 );                 if ($this->pm->additinerary($data)){                     $this->session->set_flashdata('msg','status changed successfully');                 } else {                     $this->session->set_flashdata('msg','status changed failed...try again');                 }             }              $code_send = $_post['iti_code'][0];             echo $code_send;          }      } 


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -