0

Codeigniter Code:

if(is_dir('uploads/'.$data['pet'][0]['pet_hidenum'])){
    if(isset($this->input->post('lostimage1'))){
        $filedata = explode(',', $this->input->post('lostimage1'));
        $pos  = strpos($this->input->post('lostimage1'), ';');
        $type = explode(':', substr($this->input->post('lostimage1'), 0, $pos))[1];
        $type = '.'.$type;
        $type = str_replace('image/', '', $type);
        $img['img'] = $img['img'].''.$type;
        write_file('./uploads/'.$data['pet'][0]['pet_hidenum'].'/'.$img['img'], base64_decode($filedata[1]));
    }
}

Why is this error appearing van anyone p[lease help me how can I resolve this problem?

Shah Rushabh
  • 147
  • 4
  • 16
  • http://stackoverflow.com/questions/1075534/cant-use-method-return-value-in-write-context http://stackoverflow.com/questions/6730216/cant-use-method-return-value-in-write-context http://stackoverflow.com/questions/17139264/cant-use-function-return-value-in-write-context – Luke Apr 19 '17 at 15:51
  • Possible duplicate of [Can't use method return value in write context](http://stackoverflow.com/questions/1075534/cant-use-method-return-value-in-write-context) – Luke Apr 19 '17 at 15:59
  • `$exploded = explode(':', substr($this->input->post('lostimage1'), 0, $pos)); $type = $exploded[1];` – Tpojka Apr 19 '17 at 18:01

1 Answers1

0

This happen when you are using an old version of php so you can not do explode(':', substr($this->input->post('lostimage1'), 0, $pos))[1];

Try this:

if(is_dir('uploads/'.$data['pet'][0]['pet_hidenum'])){
if(isset($this->input->post('lostimage1'))){
    $filedata = explode(',', $this->input->post('lostimage1'));
    $pos  = strpos($this->input->post('lostimage1'), ';');
    $aux = substr($this->input->post('lostimage1'), 0, $pos);
    $type = explode(':', $aux)[1];
    $type = '.'.$type;
    $type = str_replace('image/', '', $type);
    $img['img'] = $img['img'].''.$type;
    write_file('./uploads/'.$data['pet'][0]['pet_hidenum'].'/'.$img['img'], base64_decode($filedata[1]));
}
}
Nerea
  • 2,107
  • 2
  • 15
  • 14