diff options
author | c+1 | 2024-09-01 21:48:56 -0400 |
---|---|---|
committer | c+1 | 2024-09-01 21:48:56 -0400 |
commit | 94daf8ad98b19afbd4320078b9d1ee25c9fb82f1 (patch) | |
tree | 28adfead942eb55dafdf67505bc326bb3f6e2f26 /public/index.php |
Allows for the uploading of files.
Diffstat (limited to 'public/index.php')
-rw-r--r-- | public/index.php | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/public/index.php b/public/index.php new file mode 100644 index 0000000..f656154 --- /dev/null +++ b/public/index.php @@ -0,0 +1,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> |