中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

將圖片轉(zhuǎn)成base64字符串的PHP代碼

2018-07-20    來(lái)源:open-open

容器云強(qiáng)勢(shì)上線!快速搭建集群,上萬(wàn)Linux鏡像隨意使用
此代碼將幫助你學(xué)習(xí)如何將圖像轉(zhuǎn)換成一個(gè)base64字符串。
<title>Image to Base64 String</title>
<fieldset>
    <legend>Image to Base64 String</legend>
        <center>
        <form name="select_all">
                 <?php
                /**
 * @author vir0e5 a.k.a banditc0de
 * @copyright 2010 by vir0e5
 * @authorurl http://facebook.com/vir0e5.vbs
 * @Blog http://banditc0de.blogspot.com
  This code will help you to learn how we can convert an image into a base64 string!!
 */
                    echo"<h3><p>Image</p></h3>";
                    //$file = File Image yang ingin di encode 
                    //Filetype: JPEG,PNG,GIF
                    $file = "encode.jpg";
                    if($fp = fopen($file,"rb", 0))
                    {
                    $gambar = fread($fp,filesize($file));
                    fclose($fp);

                    
                    $base64 = chunk_split(base64_encode($gambar));
                    //Result
                    $encode = '<img src="data:image/jpg/png/gif;base64,' . $base64 .'" >';
                    echo $encode;
                    }    
                ?>
                <br><textarea name="text_area" rows="20" cols="70"> <? echo $encode; ?> </textarea>
                <p><input type="button" value="Select All Code" onClick="javascript:this.form.text_area.focus();this.form.text_area.select();"></p>
        </form>
        </center>
    </fieldset>

標(biāo)簽: 代碼

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請(qǐng)聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請(qǐng)與原作者聯(lián)系。

上一篇:實(shí)現(xiàn)回到頂部按紐的jQuery代碼

下一篇:加載外部?jī)?nèi)容的jQuery代碼