This repository has been archived on 2022-02-09. You can view files and clone it, but cannot push or open issues or pull requests.
huffpress/huffpress.php
Masahiko AMANO fef8f4ec00 Just fixed it all
Back to this project after over a half-year
2021-12-08 15:58:48 +03:00

17 lines
583 B
PHP

<?php
$mode = $_POST['mode'];
$file = $_FILES['file'];
if (!is_dir('./files')) {
mkdir('./files');
}
if (!file_exists('./counter.txt')){
file_put_contents('./counter.txt', '0');
}
$id = (int)file_get_contents('./counter.txt');
file_put_contents('./counter.txt', (string)($id+1));
$path = "./files/{$id}__".basename($file['name']);
move_uploaded_file($file['tmp_name'], $path);
$result = json_decode((string)shell_exec(dirname(__file__)."/huffman.py -".($mode == 'compress' ? 'c' : 'd')." \"{$path}\""));
header('Content-Type: application/json');
echo json_encode($result);
?>