Skip to content

Instantly share code, notes, and snippets.

@githubcom13
Created October 24, 2021 11:20
Show Gist options
  • Save githubcom13/b52d17942882c520f83f4a0382e92207 to your computer and use it in GitHub Desktop.
Save githubcom13/b52d17942882c520f83f4a0382e92207 to your computer and use it in GitHub Desktop.
Icon base64encode
<?php
$b64 = '';
if ( !function_exists ( 'file_get_contents' ) )
{
function file_get_contents ( $file )
{
$fp = @fopen ( $file, 'rb' );
if ( !$fp ) exit ( 'Unable to open ' . $file );
$data = fread ( $fp, filesize ( $file ) );
fclose ( $fp );
return $data;
}
}
if ( isset ( $_FILES['myfile'] ) )
{
$b64 = base64_encode ( file_get_contents ( $_FILES['myfile']['tmp_name'] ) );
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Icon base64encode</title>
</head>
<body>
<h1>Icon base64encode</h1>
<p>Select icon file (GIF image)</p>
<form action="" method="post" enctype="multipart/form-data">
<input id="file" name="myfile" type="file">
<input type="submit" value="Encode">
</form>
<?php if ( $b64 != '' ) : ?>
<br><br>
<textarea style="width: 500px;height: 400px;"><?=$b64?></textarea>
<?php endif; ?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment