php - Codeingiter : Image upload through web services -


i trying upload 1 image through web services . following code

  public function upload() {         $config['upload_path']          = './uploads/';         $config['allowed_types'] = 'gif|jpg|png|mp4|jpeg';         $config['max_size']             = 100;         $config['max_width']            = 1024;         $config['max_height']           = 768;         $this->load->library('upload', $config);         $this->upload->initialize($config);          $this->data['data']= $_files;           echo json_encode($this->data); die;           if ( ! $this->upload->do_upload('userfile'))         {                 $error = array('error' => $this->upload->display_errors());                 $this->data['data']= $error ;                  echo json_encode($this->data['data']);                  die;          }         else         {                 $data = array('upload_data' => $this->upload->data());                                         $this->data['data']= 'done' ;                   echo json_encode($this->data['data']);                  die;          } } 

if json_encode($_files) response on mobile

 data =     {         userfile =         {             error = 0;             name = pen;             size = 38238;             "tmp_name" = "/tmp/phpeseqnk";             type = jpeg;         };     }; 

when print errors array

error = "<p>the filetype attempting upload not allowed.</p>"; 

please check both responses printed , let me know how can fix .

try this. might help

$config["allowed_types"] = "image/jpeg|image/gif|image/jpg|image/png|video/mp4"; 

Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -