Created
June 19, 2013 09:26
-
-
Save addorange/5812982 to your computer and use it in GitHub Desktop.
Copy png from base64 delivery to create an image file
This file contains hidden or 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 | |
// Copy png from base64 delivery to create an image file | |
// 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 . "" . $_POST['type'] . "_" . date("Y-m-d_Hi", time()) . '.png'; | |
$success = file_put_contents($file, $data); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment