Skip to content

Instantly share code, notes, and snippets.

@mstred
Forked from jpmirandas/gist:a2b4f4951c7e8027ecb4
Last active August 29, 2015 14:22
Show Gist options
  • Save mstred/f7a5f13255f4655ed4e2 to your computer and use it in GitHub Desktop.
Save mstred/f7a5f13255f4655ed4e2 to your computer and use it in GitHub Desktop.
<?php
$filePath = @$argv[1];
$outputExt = @$argv[2];
if (!isset($filePath)) {
echo "Base64 content file hasn't been actually provided";
exit;
}
// read content from file and decode it as base64
$file = file_get_contents($filePath, FILE_TEXT);
$content = base64_decode($file);
// write output file with same name, assume .html as default extension
$result = file_put_contents(isset($outputExt) ? $filePath . $outputExt : "$filePath.html", $content, FILE_TEXT);
if (!$result) {
exit("There was an error in current operation");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment