Created
February 26, 2011 16:13
-
-
Save xjamundx/845345 to your computer and use it in GitHub Desktop.
php canvas base64 png decoder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// requires php5 | |
define('UPLOAD_DIR', 'images/'); | |
$img = $_POST['img']; | |
$img = str_replace('data:image/png;base64,', '', $img); | |
$img = str_replace(' ', '+', $img); | |
$data = base64_decode($img); | |
$file = UPLOAD_DIR . uniqid() . '.png'; | |
$success = file_put_contents($file, $data); | |
print $success ? $file : 'Unable to save the file.'; | |
?> |
Great snippet thanks 👍
@dkrasov make to run the command sudo chmod 777 "your_upload_directory"
Great snippet really helpfull to me Thank you
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks!, you solve my problem