-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload.php
More file actions
110 lines (97 loc) · 2.76 KB
/
upload.php
File metadata and controls
110 lines (97 loc) · 2.76 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
if (isset($_POST['upload_submit'])) {
if (!empty($_FILES['file']['tmp_name'])) {
if (move_uploaded_file($_FILES['file']['tmp_name'], 'uploads/' . $_FILES['file']['name'])) {
$filename = 'uploads/' . $_FILES['file']['name'];
$team = $_POST['teams'];
if ($team == 'team1') {
$attack = 1;
} elseif ($team == 'team2') {
$attack = 2;
} else {
echo "<script>alert('Select Team Please!')</script>";
echo "<script>history.back()</script>";
return;
}
$full_command = "python3 offside.py --image_path " . $filename . " --Attack " . $attack;
$output = shell_exec($full_command);
// Generate the filename for the decision file
$filename_decision = 'output/' . $_FILES['file']['name'];
// Check if the decision file exists
if (file_exists($filename_decision)) {
?>
<!DOCTYPE html>
<html>
<head>
<style>
/* CSS styles */
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
margin: 0;
padding: 0;
}
.container {
max-width: 800px;
margin: 40px auto;
background-color: #fff;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
border-radius: 4px;
padding: 20px;
}
.result {
display: flex;
align-items: center;
}
.result img {
max-width: 400px;
}
.result-text {
margin-left: 20px;
}
.result-title {
font-size: 24px;
margin-top: 0;
}
.go-back-button {
padding: 10px 20px;
background-color: #4caf50;
color: white;
border: none;
cursor: pointer;
font-size: 16px;
}
.output {
margin-top: 40px;
padding: 20px;
background-color: #f2f2f2;
border-radius: 4px;
}
</style>
</head>
<body>
<div class="container">
<h2>Result</h2>
<hr>
<div class="result">
<img id="image" src="<?php echo htmlspecialchars($filename_decision); ?>">
<div class="result-text">
<h3 class="result-title">Image uploaded and decision done.</h3>
<button class="go-back-button" onclick="history.back()">Go Back</button>
</div>
</div>
<div class="output">
<h3>Output:</h3>
<?php echo $output; ?>
</div>
</div>
</body>
</html>
<?php
} else {
echo "<p>Error</p>";
}
}
}
}
?>