Encode files in base64 to allow both text and binary input files

This commit is contained in:
bergware
2017-09-16 12:07:48 +02:00
parent aef2ae096f
commit e57e263895
2 changed files with 2 additions and 5 deletions

View File

@@ -16,14 +16,11 @@ $ini = '/var/local/emhttp/keyfile.ini';
$luks = $var['luksKeyfile'];
$text = $_POST['text'] ?? false;
$file = $_POST['file'] ?? false;
$flag = $_POST['flag'] ?? false;
if ($text) {
file_put_contents($luks, $text);
if ($flag) file_put_contents($ini,'text');
} elseif ($file) {
file_put_contents($luks, $file);
if ($flag) file_put_contents($ini,'file');
file_put_contents($luks, base64_decode(preg_replace('/^data:.*;base64,/','',$file)));
} else {
@unlink($luks);
}