2013年1月6日 星期日

[php] 將圖片以base64編碼輸出


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8;"/>
<title>test</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
</head>
<body>
<?php
$img_text='data:image/jpg;base64,'.base64_encode(file_get_contents('image/001.jpg','r'));
?>
<img src="<?php echo $img_text;?>"/>
</body>
</html>

註:


參考資料:
http://blog.upall.cn/350.html

沒有留言:

張貼留言