-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddcmd.php
More file actions
39 lines (37 loc) · 1.17 KB
/
addcmd.php
File metadata and controls
39 lines (37 loc) · 1.17 KB
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
<?php
// Check if the form was submitted
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_FILES["file"])) {
$file = $_FILES["file"];
// Check for errors during file upload
if ($file["error"] === UPLOAD_ERR_OK) {
$filename = basename($file["name"]);
$destination = "cmds/" . $filename;
// Move the uploaded file to the destination directory
if (move_uploaded_file($file["tmp_name"], $destination)) {
echo "File uploaded successfully.";
} else {
echo "Error uploading file.";
}
} else {
echo "Error: " . $file["error"];
}
} else {
// Display the HTML form for file upload
echo '
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>File Upload</title>
</head>
<body>
<h2>Upload New CMDS</h2>
<form action="' . $_SERVER["PHP_SELF"] . '" method="post" enctype="multipart/form-data">
<input type="file" name="file">
<button type="submit" name="submit">Upload</button>
</form>
</body>
</html>';
}
?>