Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //define('IMAGE_DIR', $_SERVER['DOCUMENT_ROOT']."/images/");
- //echo IMAGE_DIR;
- // 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.';
- /*
- $filename=$_REQUEST['filename'];
- $myfile = fopen($filename, "w") or die("Unable to open file!");
- $data = base64_decode($_REQUEST['image']);
- file_put_contents($filename, $data);
- fclose($myfile);
- */
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement