Codeigniter代码:
$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);
$img1 = $img['img'].''.$type;
write_file('./uploads/'.$data['pet_hidenum'].'/'.$img1, $filedata[1]);
我的代码工作正常。当我从服务器下载图像并在paint或chrome中打开图像时,它显示错误无效位图如何解决此错误?
答案 0 :(得分:0)
尝试以下几点:
$image = imagecreatefromjpeg($filename);
echo '<img src="data:image/jpeg;base64,'.base64_encode(imagejpeg($image)).'" />';
有关此https://delboy1978uk.wordpress.com/2014/12/01/outputting-images-as-base64-encoded-strings/
的详细信息,请参阅此帖子