Showing posts with label How to Upload base64 Encoded Image in Codeigniter. Show all posts
Showing posts with label How to Upload base64 Encoded Image in Codeigniter. Show all posts

Monday, 7 March 2016

How to Upload base64 Encoded Image in Codeigniter





$image = base64_decode($this->input->post("image_base64_string"));
// decoding base64 string value
$image_name = md5(uniqid(rand(), true));// image name generating with random number with 32 characters
$filename = $image_name . '.' . 'png';
//rename file name with random number
$path = set_realpath('product/image/');
//image uploading folder path
file_put_contents($path . $filename, $image);
// image is bind and upload to respective folder