Just fixed it all
Back to this project after over a half-year
This commit is contained in:
+9
-4
@@ -1,12 +1,17 @@
|
||||
<?php
|
||||
$mode = $_POST['mode'];
|
||||
$file = $_FILES['file'];
|
||||
if (!is_dir(dirname(__file__) . '/files')) {
|
||||
mkdir(dirname(__file__) . '/files');
|
||||
if (!is_dir('./files')) {
|
||||
mkdir('./files');
|
||||
}
|
||||
$path = dirname(__file__) . '/files/' . basename($file['name']);
|
||||
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('python ' . dirname(__file__) . '/huffman.py -' . ($mode == 'compress' ? 'c' : 'd') . ' "' . $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);
|
||||
?>
|
||||
Reference in New Issue
Block a user