-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbookmarks-view.php
More file actions
42 lines (42 loc) · 1.15 KB
/
bookmarks-view.php
File metadata and controls
42 lines (42 loc) · 1.15 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
<?php
$error = 0;
$allowedExts = array("html", "htm");
$temp = explode(".", $_FILES["file"]["name"]);
$extension = end($temp);
if ((($_FILES["file"]["type"] == "text/html"))
&& ($_FILES["file"]["size"] < 20000000)
&& in_array($extension, $allowedExts)) {
if ($_FILES["file"]["error"] > 0) {
echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
$error = 1;
} else {
echo "Upload: " . $_FILES["file"]["name"] . "<br>";
echo "Type: " . $_FILES["file"]["type"] . "<br>";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
$temp = $_FILES["file"]["tmp_name"];
echo "Temp file: " . $temp . "<br>";
$file = "";
if(isset($_POST['dir']) && strlen($_POST['dir']) > 0)
$file = $_POST['dir'] . "/";
$file .= $_FILES["file"]["name"];
if (file_exists($file)) {
unlink($file);
}
$msg = "stored in: " . $file . "<br>";
if (move_uploaded_file($temp, $file)) {
echo $msg;
} else {
echo "NOT " . $msg;
$error = 1;
}
}
} else {
echo "Invalid file";
$error = 1;
}
?>
<script>
var func = window.top.window.finishUpload;
if (typeof(func) === "function")
func(<?php echo $error; ?>);
</script>