Unable to upload a base64 encoded image using Codeigniter

前端 未结 2 1060
情深已故
情深已故 2021-01-14 01:30

I have to upload a base64 encoded image that i am receiving from android application. I am using php codeigniter framework. While searching through the forum, the question

2条回答
  •  感情败类
    2021-01-14 01:51

    You are aware, that if you are receiving an Base64 encoded image, as a string, then you do not need to use the Upload class.

    Instead, you just need to decode it using base64_decode and then use fwrite/file_put_contents to save the decoded data...

    $img = imagecreatefromstring(base64_decode($string)); 
    if($img != false) 
    { 
       imagejpeg($img, '/path/to/new/image.jpg'); 
    }  
    

    Credit: http://board.phpbuilder.com/showthread.php?10359450-RESOLVED-Saving-Base64-image.

提交回复
热议问题