The example in this article describes how the PHP implementation saves the Base64 format picture in the specified directory. Share to everyone for your reference, specific as follows:
<?php
Header (' Content-type:text/html;charset=utf-8 ');
$base 64_image_content = $_post[' imgBase64 '];
Match the format of the picture
if (Preg_match (data:\s*image\/(\w+); base64,)/', $base 64_image_content, $result)) {
$type = $ RESULT[2];
$new _file = "upload/active/img/". Date (' Ymd ', Time ()). " /";
if (!file_exists ($new _file))
{
//check if there is a folder, create it if not, and give the highest permission
mkdir ($new _file, 0700);
}
$new _file = $new _file.time (). ". {$type} ";
if (file_put_contents ($new _file, Base64_decode (Str_replace ($result [1], ', $base 64_image_content))) {
echo ' New File Save success: ', $new _file;
} else{
Echo ' new file save failed ';
}
? >
PS: Here again for you to recommend several online picture Tools for everyone to use the reference
Picture converted to BASE64 encoded online tool:
Http://tools.jb51.net/transcoding/img2base64
Online Email Email icon Production tool:
Http://tools.jb51.net/email/emaillogo
Online PS image processing tools:
http://tools.jb51.net/aideddesign/webps
Online picture format conversion (jpg/bmp/gif/png) Tool:
Http://tools.jb51.net/aideddesign/picext
ico icon Online generation tool:
Http://tools.jb51.net/aideddesign/ico_img
For more information on PHP related content readers can view the site topics: "PHP graphics and pictures Operating skills summary", "Basic PHP Grammar Introductory Course", "PHP Operations and Operator Usage Summary", "PHP object-oriented Program Design Introductory Course", "PHP Network Programming Skills Summary", "PHP array (Array) Operations tips Encyclopedia, "PHP string (String) Usage Summary", "Php+mysql Database operation Introduction Tutorial" and "PHP Common database Operation tips Summary"
I hope this article will help you with the PHP program design.