-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathform.php
More file actions
62 lines (62 loc) · 1.94 KB
/
form.php
File metadata and controls
62 lines (62 loc) · 1.94 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
<!DOCTYPE html>
<html>
<body>
<?php
$uploadOk1 = 1;
$uploadOk2 = 1;
if (isset($_POST['submit'])) {
$target_dir = "./Upload/";
$target_file1 = $target_dir . basename($_FILES["fileToUpload1"]["name"]);
$target_file2 = $target_dir . basename($_FILES["fileToUpload2"]["name"]);
$fileType1 = pathinfo($target_file1, PATHINFO_EXTENSION);
$fileType2 = pathinfo($target_file2, PATHINFO_EXTENSION);
// Check if file is a .cfg
if ($fileType1 != "cfg")
echo "<div class='error'>Error character 1, only .cfg files are allowed.<br></div>";
else
$uploadOk1 = 0;
if ($fileType2 != "cfg")
{
if ($fileType2 != "")
echo "<div class='error'>Error character 2, only .cfg files are allowed.<br></div>";
}
else
$uploadOk2 = 0;
}
?>
<div class="form">
<form action="index.php" method="post" enctype="multipart/form-data">
<input type="file" name="fileToUpload1" id="fileToUpload1" required>
<br>
<input type="file" name="fileToUpload2" id="fileToUpload2">
<br>
<input type="submit" value="Upload .cfg file" name="submit">
</form>
</div>
<?php
if ($uploadOk1 == 0) {
if (move_uploaded_file($_FILES["fileToUpload1"]["tmp_name"], $target_file1) == false) {
echo "Sorry, there was an error uploading your file.<br>";
$uploadOk1 = 1;
} else {
print "<div class='main'><div class='unit_to_compare1'>";
include("open1.php");
include("chara_page.php");
print "</div>";
}
if ($uploadOk2 == 0) {
if (move_uploaded_file($_FILES["fileToUpload2"]["tmp_name"], $target_file2) == false) {
echo "Sorry, there was an error uploading your file.<br>";
$uploadOk2 = 1;
} else {
print "<div class='unit_to_compare2'>";
include("open2.php");
include("chara_page.php");
print "</div></div>";
}
}
}
?>
</div>
</body>
</html>