Last active
May 25, 2021 11:45
-
-
Save byeblogs/55ffdd9c891f3ca8c8d40deecacd713a to your computer and use it in GitHub Desktop.
Upload Images
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
$pathTo = "/Applications/XAMPP/xamppfiles/htdocs/zmg-development/upload_src/directory/"; | |
$img_src = $_POST['img_src']; | |
$img_name = $_POST['img_name']; | |
$data = base64_decode(preg_replace('#^data:image/[^;]+;base64,#', '', $img_src)); | |
$file = $pathTo . $img_name; | |
$success = file_put_contents($file, $data); | |
print $success ? $file : 'Unable to save the file.'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment