Base64在线编码解码实现代码 演示与下载
前端之家收集整理的这篇文章主要介绍了
Base64在线编码解码实现代码 演示与下载,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在线演示地址:
gb2312版本 http://tools.jb51.cc/tools/base64_decode-gb2312.php
utf8版本 http://tools.jb51.cc/tools/base64_decode-utf8.php
<div class="codetitle"><a style="CURSOR: pointer" data="28910" class="copybut" id="copybut28910" onclick="doCopy('code28910')"> 代码如下:
<div class="codebody" id="code28910">
<?
PHP header('Content-Type: text/html; charset=gb2312');
$txt1 = stripslashes(trim( @$_POST['text1']));
$button = @$_POST['button'];
$down = @trim($_GET['down']);
if ($down==1) {
header("Content-type: command");
header("Content-Disposition: attachment; filename=base64_decode.txt");
$contents = file_get_contents(basename($_SERVER['
PHP_SELF']));
echo $contents;
exit;
}
?>
<html xmlns="
http://www.w3.org/1999/xhtml">
<
Meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<
Meta content="Base64在线编码解码" name="keywords">
Base64在线编码解码 gb2312 <body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">
<table border="0" width="100%" cellspacing="0" cellpadding="0" height="100%">
<tr><td height="20" bgcolor="#CCCCCC" align =right style="padding-right:5px;">
</td></tr><tr>
<form name="form1" method="post" action="">
Base64在线编码解码 gb2312 <a href="?down=1">源码下载
请输入转换的地址: <textarea name="text1" rows="14" class="bginput" style="width:520px;"><?php echo htmlspecialchars($txt1,ENT_QUOTES);?>
请选择转换的方式: <textarea rows="14" class="bginput" style="width:520px;"><?PHP if($button=="编码") echo base64_encode($txt1); if($button=="解码") echo mb_convert_encoding(base64_decode($txt1),"gb2312","UTF-8"); ?>
</td></tr> <tr><td height="10"></td></tr><tr> | </td> </tr> </table>
|