Skip to content

Instantly share code, notes, and snippets.

@cereda
Created June 25, 2011 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cereda/1046383 to your computer and use it in GitHub Desktop.
Save cereda/1046383 to your computer and use it in GitHub Desktop.
PHP script to decode a Base64 string from a file
<?php
// Note: this script was written just for testing
// purposes. It has no error checking and other
// controls. DO NOT RUN THIS COMMAND WITHOUT
// REDIRECTING THE OUTPUT TO A FILE, e.g.,
// convert.php mystring.txt > out.png
// open the file
$handler = fopen($argv[1], 'r');
// fetch the contents
$data = fread($handler, filesize($argv[1]));
// close the file
fclose($handler);
// decode the contents and print
echo base64_decode($data);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment