2017-04-19 35 views
0

笨代碼:如何將BASE64轉換爲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

很好,試圖[php.net關於BASE64_DECODE(http://php.net的解決方案/manual/en/function.base64-decode.php)呢? - 尤其是銀色網點de **之一的托比亞斯。不能嘗試它.. –

+0

不,我沒有嘗試過。但爲什麼它不起作用,請幫助我。 –

回答