[英]How to upload base64encoded image in codeigniter
我有一個base64編碼的圖像字符串$imgcode
,這是一個base64編碼的圖像,我想使用codeigniter上傳它。
這是我在做什么 -
$this->Photo_model->uploadPhoto($userdir,base64_decode($imgCode)
uploadPhoto函數是這樣的:
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;
}
}
}
圖像未上傳。 這是正確的方法嗎?
當base64_decode用於解碼大文件時,有報告稱存在各種故障。 你可以在這里看到更多關於這些問題的信息http://www.php.net/manual/en/function.base64-decode.php#105512
我建議像這樣拆分字符串$decodedstring=base64_decode(chunk_split($encodedstring));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.