Codeigniter代码:
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]));
}
}
为什么这个错误出现在任何人身上[租约帮助我如何解决这个问题?
答案 0 :(得分:0)
当您使用旧版本的php时,会发生这种情况,因此您无法执行explode(':', substr($this->input->post('lostimage1'), 0, $pos))[1];
试试这个:
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]));
}
}