-
Notifications
You must be signed in to change notification settings - Fork 1
/
upload.php
37 lines (31 loc) · 1.22 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
<?php
include('config.php');
// We automatically generate new names for processed orders. Names will be UUID's
$new_name = gen_uuid();
$target_file = $orderdir . '/' . $new_name . '.xml';
$uploadOk = 1;
if ($_FILES["fileToUpload"]["size"] > 50000) {
echo "Sorry, your file is too large.";
$uploadOk = 0;
}
// File must be an XML file. Currently we don't bother verifying if it is proper XML file
// If it's not - it will fail in the view order screen anyway
$FileType = pathinfo($target_file,PATHINFO_EXTENSION);
if($FileType != "xml" ) {
echo "Sorry, only XML files are allowed.";
$uploadOk = 0;
}
if ($uploadOk == 0) {
echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "<!DOCTYPE html><html><head><title>List of previous orders</title><link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\"></head><body>";
echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded as new order $new_name.";
echo "<br><br>";
echo "<b id=\"logout\"><a href=\"profile.php\">Go back</a></b></div></body></html>";
} else {
echo "Sorry, there was an error uploading your file.";
}
}
?>