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

12 lines
474 B
PHP

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