images-uploaden
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
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
<?php
if(isset($_POST["bevestiging"])){
$naam = $_POST["naam"];
$allow[0] = "pjpeg";
$allow[1] = "gif";
$allow[2] = "png";
$allow[3] = "pjpg";
$allow[4] = "jpg";
$allow[5] = "jpeg";
$allow[6] = "x-png";
$locatie = "images/";
global $_FILES;
$f_extentie = $_FILES["file"]["type"];
$extentie = explode("image/", $f_extentie);
for($i = 0; $i < count($allow); $i++){
if(strtolower($extentie[1] == $allow[$i])){
$extentie_check = "ok";
$i = count($allow) + 5;
}
}
if(file_exists($locatie.$naam)){
echo "Kies een andere naam voor het bestand<br><br>";
}else{
if($extentie_check){
if(is_uploaded_file($file)){
move_uploaded_file($file, $locatie.$naam);
list($width, $height, $attr, $type) = getimagesize("images/$naam");
$size = filesize("images/$naam");
if($width > 120 or $height > 200){
echo "Maximale grootte 120x200. Probeer het opnieuw.<br><br>";
unlink("images/$naam");
}elseif($size > 1000000){
echo "Uw bestand gaat over het limiet van 1 mb heen. De grootte van uw bestand is $size.<br><br>";
unlink("images/$naam$ext");
}else{
echo "Uw bestand is upgeload<br><br><img src='images/$naam'><br><br>URL: url/images/$naam";
}
}
}else{ echo "Verkeerde extentie.<br><br>"; }
}
echo "<a href='javascript:history.back();'>Terug</a>";
}else{
?>
<table width="450">
<tr>
<td align="left" width="100%"><strong>Upload file:</strong><br><br>* Max file size: 1 MB<br>* Maximum size picture 120x200<br>* Extenties: jpg(jpeg), gif, png<br><br></td>
</tr>
</table>
<table width="450">
<form action="<?php $_SERVER['PHP_SELF'];?>" method="post" enctype="multipart/form-data">
<input type="hidden" name="bevestiging" value="1">
<tr>
<td align="right" width="10%">File:</td>
<td align="left" width="90%"><input type="file" name="file"></td>
</tr>
<tr>
<td align="right" width="10%">Name:</td>
<td align="left" width="90%"><input type="text" name="naam"></td>
</tr>
<tr>
<td align="right" width="10%"></td>
<td align="left" width="90%"><input type="submit" value="Upload"></td>
</tr>
</form>
</table>
<?php } ?>
if(isset($_POST["bevestiging"])){
$naam = $_POST["naam"];
$allow[0] = "pjpeg";
$allow[1] = "gif";
$allow[2] = "png";
$allow[3] = "pjpg";
$allow[4] = "jpg";
$allow[5] = "jpeg";
$allow[6] = "x-png";
$locatie = "images/";
global $_FILES;
$f_extentie = $_FILES["file"]["type"];
$extentie = explode("image/", $f_extentie);
for($i = 0; $i < count($allow); $i++){
if(strtolower($extentie[1] == $allow[$i])){
$extentie_check = "ok";
$i = count($allow) + 5;
}
}
if(file_exists($locatie.$naam)){
echo "Kies een andere naam voor het bestand<br><br>";
}else{
if($extentie_check){
if(is_uploaded_file($file)){
move_uploaded_file($file, $locatie.$naam);
list($width, $height, $attr, $type) = getimagesize("images/$naam");
$size = filesize("images/$naam");
if($width > 120 or $height > 200){
echo "Maximale grootte 120x200. Probeer het opnieuw.<br><br>";
unlink("images/$naam");
}elseif($size > 1000000){
echo "Uw bestand gaat over het limiet van 1 mb heen. De grootte van uw bestand is $size.<br><br>";
unlink("images/$naam$ext");
}else{
echo "Uw bestand is upgeload<br><br><img src='images/$naam'><br><br>URL: url/images/$naam";
}
}
}else{ echo "Verkeerde extentie.<br><br>"; }
}
echo "<a href='javascript:history.back();'>Terug</a>";
}else{
?>
<table width="450">
<tr>
<td align="left" width="100%"><strong>Upload file:</strong><br><br>* Max file size: 1 MB<br>* Maximum size picture 120x200<br>* Extenties: jpg(jpeg), gif, png<br><br></td>
</tr>
</table>
<table width="450">
<form action="<?php $_SERVER['PHP_SELF'];?>" method="post" enctype="multipart/form-data">
<input type="hidden" name="bevestiging" value="1">
<tr>
<td align="right" width="10%">File:</td>
<td align="left" width="90%"><input type="file" name="file"></td>
</tr>
<tr>
<td align="right" width="10%">Name:</td>
<td align="left" width="90%"><input type="text" name="naam"></td>
</tr>
<tr>
<td align="right" width="10%"></td>
<td align="left" width="90%"><input type="submit" value="Upload"></td>
</tr>
</form>
</table>
<?php } ?>