upload-files-naar-verschillende-directorys
Gesponsorde koppelingen
PHP script bestanden
Code (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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php
echo "<title>Upload files</title>";
if (!is_dir("school")) {
die ("dir bestaat niet");
}
if ($_FILES['userfile']) {
$message = do_upload($upload_dir, $upload_url);
}
else {
$message = "Upload file";
}
function do_upload($upload_dir, $upload_url) {
if($_POST["dir"]=="school") {
$upload_dir = "school/";
}
elseif($_POST["dir"]=="mysql") {
$upload_dir = "mysql backup/";
}
elseif($_POST["dir"]=="outlook") {
$upload_dir = "outlook backup/";
}
else {
$upload_dir = "overig/";
}
$temp_name = $_FILES['userfile']['tmp_name'];
$file_name = $_FILES['userfile']['name'];
$file_type = $_FILES['userfile']['type'];
$file_size = $_FILES['userfile']['size'];
$result = $_FILES['userfile']['error'];
$file_url = $upload_url.$file_name;
$file_path = $upload_dir.$file_name;
//File Name Check
if ( $file_name =="") {
$message = "Foute file name";
return $message;
}
//File Size Check
else if ( $file_size > 500000) {
$message = "Groter dan 500k.";
return $message;
}
//File Type Check
else if ( $file_type == "text/plain" ) {
$message = "Sorry, geen scripts uploaden" ;
return $message;
}
$result = move_uploaded_file($temp_name, $file_path);
$message = ($result)?"File url <a href=$file_url>$file_url</a>" :
"Klopt iets niet met de file.";
return $message;
}
?>
<div align="center"><form name="upload" id="upload" ENCTYPE="multipart/form-data" method="post">Upload bestand: <input type="file" id="userfile" name="userfile"><br>
School: <input type="radio" name="dir" value="school"> Overig: <input type="radio" name="dir" value="overig"> MySQL backup: <input type="radio" name="dir" value="mysql"> Outlook backups: <input type="radio" name="dir" value="outlook"><br><input type="submit" name="upload" value="Upload"></div>
</form>
School bestanden:<br>
<?php
$handel = opendir('school');
while (false !== ($file = readdir($handel))) {
if (($file !== ".") and ($file !== "..")) {
list($filename, $ext) = explode(".", $file);
list($main, $sub, $include) = explode("/", $PHP_SELF);
echo "<a href=\"school/$file\" target=\"_blank\"";
if ($inc==$file) echo " selected";
echo">$file</a><br>\n";
}
}
?><br>
Overige bestanden:<br>
<?php
$handel = opendir('overig');
while (false !== ($file = readdir($handel))) {
if (($file !== ".") and ($file !== "..")) {
list($filename, $ext) = explode(".", $file);
list($main, $sub, $include) = explode("/", $PHP_SELF);
echo "<a href=\"overig/$file\" target=\"_blank\"";
if ($inc==$file) echo " selected";
echo">$file</a><br>\n";
}
}
?><br>
MySQL backups:<br>
<?php
$handel = opendir('mysql backup');
while (false !== ($file = readdir($handel))) {
if (($file !== ".") and ($file !== "..")) {
list($filename, $ext) = explode(".", $file);
list($main, $sub, $include) = explode("/", $PHP_SELF);
echo "<a href=\"mysql backup/$file\" target=\"_blank\"";
if ($inc==$file) echo " selected";
echo">$file</a><br>\n";
}
}
?><br>
Outlook backups:<br>
<?php
$handel = opendir('outlook backup');
while (false !== ($file = readdir($handel))) {
if (($file !== ".") and ($file !== "..")) {
list($filename, $ext) = explode(".", $file);
list($main, $sub, $include) = explode("/", $PHP_SELF);
echo "<a href=\"outlook backup/$file\" target=\"_blank\"";
if ($inc==$file) echo " selected";
echo">$file</a><br>\n";
}
}
?><br><br>
<div align="center"><a href="http://www.powerwebber.nl" target="_Blank">powerwebber.nl</a></div>
echo "<title>Upload files</title>";
if (!is_dir("school")) {
die ("dir bestaat niet");
}
if ($_FILES['userfile']) {
$message = do_upload($upload_dir, $upload_url);
}
else {
$message = "Upload file";
}
function do_upload($upload_dir, $upload_url) {
if($_POST["dir"]=="school") {
$upload_dir = "school/";
}
elseif($_POST["dir"]=="mysql") {
$upload_dir = "mysql backup/";
}
elseif($_POST["dir"]=="outlook") {
$upload_dir = "outlook backup/";
}
else {
$upload_dir = "overig/";
}
$temp_name = $_FILES['userfile']['tmp_name'];
$file_name = $_FILES['userfile']['name'];
$file_type = $_FILES['userfile']['type'];
$file_size = $_FILES['userfile']['size'];
$result = $_FILES['userfile']['error'];
$file_url = $upload_url.$file_name;
$file_path = $upload_dir.$file_name;
//File Name Check
if ( $file_name =="") {
$message = "Foute file name";
return $message;
}
//File Size Check
else if ( $file_size > 500000) {
$message = "Groter dan 500k.";
return $message;
}
//File Type Check
else if ( $file_type == "text/plain" ) {
$message = "Sorry, geen scripts uploaden" ;
return $message;
}
$result = move_uploaded_file($temp_name, $file_path);
$message = ($result)?"File url <a href=$file_url>$file_url</a>" :
"Klopt iets niet met de file.";
return $message;
}
?>
<div align="center"><form name="upload" id="upload" ENCTYPE="multipart/form-data" method="post">Upload bestand: <input type="file" id="userfile" name="userfile"><br>
School: <input type="radio" name="dir" value="school"> Overig: <input type="radio" name="dir" value="overig"> MySQL backup: <input type="radio" name="dir" value="mysql"> Outlook backups: <input type="radio" name="dir" value="outlook"><br><input type="submit" name="upload" value="Upload"></div>
</form>
School bestanden:<br>
<?php
$handel = opendir('school');
while (false !== ($file = readdir($handel))) {
if (($file !== ".") and ($file !== "..")) {
list($filename, $ext) = explode(".", $file);
list($main, $sub, $include) = explode("/", $PHP_SELF);
echo "<a href=\"school/$file\" target=\"_blank\"";
if ($inc==$file) echo " selected";
echo">$file</a><br>\n";
}
}
?><br>
Overige bestanden:<br>
<?php
$handel = opendir('overig');
while (false !== ($file = readdir($handel))) {
if (($file !== ".") and ($file !== "..")) {
list($filename, $ext) = explode(".", $file);
list($main, $sub, $include) = explode("/", $PHP_SELF);
echo "<a href=\"overig/$file\" target=\"_blank\"";
if ($inc==$file) echo " selected";
echo">$file</a><br>\n";
}
}
?><br>
MySQL backups:<br>
<?php
$handel = opendir('mysql backup');
while (false !== ($file = readdir($handel))) {
if (($file !== ".") and ($file !== "..")) {
list($filename, $ext) = explode(".", $file);
list($main, $sub, $include) = explode("/", $PHP_SELF);
echo "<a href=\"mysql backup/$file\" target=\"_blank\"";
if ($inc==$file) echo " selected";
echo">$file</a><br>\n";
}
}
?><br>
Outlook backups:<br>
<?php
$handel = opendir('outlook backup');
while (false !== ($file = readdir($handel))) {
if (($file !== ".") and ($file !== "..")) {
list($filename, $ext) = explode(".", $file);
list($main, $sub, $include) = explode("/", $PHP_SELF);
echo "<a href=\"outlook backup/$file\" target=\"_blank\"";
if ($inc==$file) echo " selected";
echo">$file</a><br>\n";
}
}
?><br><br>
<div align="center"><a href="http://www.powerwebber.nl" target="_Blank">powerwebber.nl</a></div>