如何在codeigniter中上传base64编码的图像

编程入门 行业动态 更新时间:2024-10-26 16:29:42
本文介绍了如何在codeigniter中上传base64编码的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个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编码的图像

本文发布于:2023-11-26 19:34:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634916.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图像   上传   如何在   codeigniter

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!