summaryrefslogtreecommitdiff
path: root/public/index.php
blob: f65615409da257f3e06c8754da8e0ae29acf999b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php

include '../config/config.php';

if (
    $_SERVER['REQUEST_METHOD'] == 'POST' &&
    isset($_FILES['file'])
) {
    $f = $_FILES['file'];
    $id = shell_exec($ID_CMD);
    $targetf = $UPLOAD_DIR . $id;

    if ($f['size' > $UPLOAD_MAX_SZ]) {
        echo "File too large.";
    } else {
        if (move_uploaded_file($f['tmp_name'], $targetf)) {
            $cmd = escapeshellcmd(
                "$FILE_PROCESSING_CMD " .
                escapeshellarg($targetf)
            );

            shell_exec($cmd);
            echo "Uploaded.";
        } else {
            echo "Error uploading.";
        }
    }
}

?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>i2</title>
</head>
<body>
    <h1>Upload File</h1>
    <form action="index.php" method="post" enctype="multipart/form-data">
        <label for="file">Choose file:</label>
        <input type="file" id="file" name="file" required>
        <button type="submit">Upload</button>
    </form>
</body>
</html>