Example of a PHP implementation picture showing in base64

Source: Internet
Author: User
Tags base64

This is the data URI scheme defined in RFC2397, the purpose is to embed some small data directly into the Web page, so that no longer load from the external file, such as the string of characters above, is actually a picture, these characters are copied sticky paste to the Firefox address bar and turn to, you can see.

In the data URI above, data represents the contract name for the acquisition, Image/jpeg is the data type name, base64 is the encoding method of the data, followed by the Image/jpeg file Base64 encoded data.

The types currently supported by Data URI scheme are:

Data:text/plain, Text data
data:text/html,html Code
Data:text/html;base64,base64 coded HTML code
DATA:TEXT/CSS,CSS Code
Data:text/css;base64,base64 coded CSS Code
Data:text/javascript,javascript Code
Data:text/javascript;base64,base64 coded JavaScript code
DATA:IMAGE/GIF;BASE64,BASE64 encoded GIF image data
DATA:IMAGE/PNG;BASE64,BASE64 encoded PNG image data
DATA:IMAGE/JPEG;BASE64,BASE64 encoded JPEG image data
DATA:IMAGE/X-ICON;BASE64,BASE64 encoded icon image data


$img _file = ' https://img.alicdn.com/bao/uploaded/TB1eaiELpXXXXcPXpXXSutbFXXX.jpg ';
$img _info = getimagesize ($img _file);
$img _src = "data:{$img _info[' mime ']};base64,". Base64_encode (file_get_contents ($img _file));
Exit ("

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.