-
Notifications
You must be signed in to change notification settings - Fork 1
/
upload.php
executable file
·48 lines (38 loc) · 1.12 KB
/
upload.php
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
<!DOCTYPE html>
<html>
<body>
<?php
include('password.inc');
if(isset($_POST['submit'])){
$pwd=$_POST['password'];
$target_dir = "./";
$target_file = "segnalazioni.csv";
unlink("segnalazioni.csv");
$uploadOk = 1;
$FileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
// Check if image file is a actual image or fake image
$fileTmpLoc = $_FILES["fileToUpload"]["tmp_name"];
$check = mime_content_type($fileTmpLoc);
if($check == 'text/csv' or $check== 'text/plain') {
if ($pwd != $storedpassword){
echo "bad username or password";
}
echo "File is ok - " . $check . ".";
move_uploaded_file($fileTmpLoc,$target_file);
$uploadOk = 1;
} else {
echo $check." File is not a csv .";
$uploadOk = 0;
}
}
?>
<form action="upload.php" method="post" enctype="multipart/form-data">
Set user and password:<br>
<input type="text" name="username" id="usrname"><br>
<input type="password" name="password" id="password"><br>
Select file to upload:<br>
<input type="file" name="fileToUpload" id="fileToUpload"><br>
<input type="submit" value="Upload File" name="submit">
</form>
</body>
</html>