我有一个base64编码图像字符串 $ imgcode 这是一个base64编码图像,我想使用codeigniter上传它。
I have a base64 encoded image string $imgcode which is a base64 encoded image, and I want to upload it using codeigniter.
这是我在做什么 -
Here is what i am doing -
$this->Photo_model->uploadPhoto($userdir,base64_decode($imgCode)uploadPhoto函数是这样:
The uploadPhoto function is this:
public function uploadPhoto($path,$img){ //echo $img; //echo $path; $config['upload_path'] = $path; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = '1000'; $config['max_width'] = '1024'; $config['max_height'] = '768'; $this->load->library('upload', $config); if(!$this->upload->do_upload($img)){ return FALSE; } else{ $fInfo = $this->upload->data(); $this->createThumbnail($fInfo['file_name'],$fInfo['file_path']); $this->load->model('Photo_model'); if($this->Photo_model->savePhotoInfo($fInfo['file_name'],$path)){ return true; } else{ return false; } } }。这是正确的方法吗?
The image is not getting uploaded. Is this the correct way?
推荐答案当使用base64_decode解码大文件时,您可以在这里查看更多有关问题的资讯 http://www.php / manual / en / function.base64-decode.php#105512
There have been reports of various kinds of failures when base64_decode is used to decode large files. You can see more about the problems here www.php/manual/en/function.base64-decode.php#105512
我建议像这样分割字符串 $ decodedstring = base64_decode(chunk_split($ encodedstring));
I recommend splitting the string like this $decodedstring=base64_decode(chunk_split($encodedstring));
更多推荐
如何在codeigniter中上传base64编码的图像
发布评论