Codeigniter | Save Base64 image to file Codeigniter | Save Base64 image to file codeigniter codeigniter

Codeigniter | Save Base64 image to file


You can also use

$decoded=base64_decode($base64Image);file_put_contents('newImage.JPG',$decoded);

Reference Link: http://j-query.blogspot.in/2011/02/save-base64-encoded-canvas-image-to-png.html


Use tempnam() to get a unique file name in a directory writable by the script. You can map a session variable "thisUsersTempFile" to that file name.

Or you can store the association somewhere else if it is not temporary. If you need to clean up the tmp files, you would probably need to do that since I don't think you can hook the session destruction. You could poll for existing sessions and delete the tmpfiles associated with the sessions that were destroyed. You could use a cron job for that.