Verkleine plaatje
Ik heb een script gemaakt, maar hij werkt niet.
Kan iemand er met een kritsch oog naar kijken en die zo nodig verbeteren.
Ik heb al overal gezocht, maar kan het juiste nog miet vinden
Wouter
<
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
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
<?
/*
Bugs: [email protected]
V1.1.1: 2004-07-13 1:26
Updates:
V1.1.1
Hij telde het aantal upload boxen niet goed, nu wel.
Website: http://www.myimages.nl
*/
//Instellingen
$forms = 2; //Standaard aantal file uploads
$user = falsh; //User kan aangeven dat hij meer files wil uploaden
$max_size = 100000000; //Maximale bestands grootte, 0 voor ongelimiteerd
$max_thumb = 150;
$max_image = 334;
$max_cat = 100; //Maximale hoogte dan wel breedte van de thumb.
$ext = "jpg jpeg gif png"; // Welke extensies kunnen er worden geupload ( als alles mag dan niks invullen )
//Script
// Toegestaande extensies opvragen
$ext = strtolower($ext);
$ext = explode(" ", $ext);
$aantal = count($ext);
if(isset($_POST['forms']) && $user==TRUE){
$forms=$_POST['forms'];
}
?>
/*
Bugs: [email protected]
V1.1.1: 2004-07-13 1:26
Updates:
V1.1.1
Hij telde het aantal upload boxen niet goed, nu wel.
Website: http://www.myimages.nl
*/
//Instellingen
$forms = 2; //Standaard aantal file uploads
$user = falsh; //User kan aangeven dat hij meer files wil uploaden
$max_size = 100000000; //Maximale bestands grootte, 0 voor ongelimiteerd
$max_thumb = 150;
$max_image = 334;
$max_cat = 100; //Maximale hoogte dan wel breedte van de thumb.
$ext = "jpg jpeg gif png"; // Welke extensies kunnen er worden geupload ( als alles mag dan niks invullen )
//Script
// Toegestaande extensies opvragen
$ext = strtolower($ext);
$ext = explode(" ", $ext);
$aantal = count($ext);
if(isset($_POST['forms']) && $user==TRUE){
$forms=$_POST['forms'];
}
?>
<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
<title>Fotoboek</title>
</head>
<body>
<table width="334" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><strong><font color="#006666" size="5" face="Geneva, Arial, Helvetica, sans-serif">Fotoboek</font></strong></td>
</tr>
</table>
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
132
133
134
135
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
132
133
134
135
<?
if($go=="uploaden"){
$aantal=count($_FILES['image']['type']);
$i=0;
for($i=0;$i<$aantal;$i++){
$foto_name=rand(1,9999)."_".time();
if(!empty($_FILES['image']['tmp_name'][$i])){
$type= $_FILES['image']['type'][$i];
// Bestands naam opvragen
$bestand2 = explode("\\", $_FILES['image']['name'][$i]);
$laatste = count($bestand2) - 1;
$bestand2 = "$bestand2[$laatste]";
// Extensie van bestand opvragen
$bestand3 = explode(".", $bestand2);
$laatste = count($bestand3) - 1;
$bestand3 = "$bestand3[$laatste]";
$bestand3 = strtolower($bestand3);
for ($tel = 0;$tel < $aantal; $tel++){
if ($bestand3 == $ext[$tel]){
$extfout = "nee";
}
}
if($type == "image/gif" OR $type == "image/pjpeg" OR $type == "image/x-png" OR $type == "image/jpeg"){
if(!empty($max_size) && $_FILES['image']['size'][$i] > $max_size){
echo"Bestand is te groot: ".$_FILES['image']['size'][$i]." / ".$max_size."<br>\n";
}elseif(!isset($extfout)){
}else{
if(move_uploaded_file($_FILES['image']['tmp_name'][$i], "./img/".$foto_name.".".$bestand3)){
// hier is het offciele bestand helemaal klaar
if($type == "image/gif"){
$photo = imagecreatefromgif("./img/".$foto_name.".".$bestand3);
}elseif($type == "image/pjpeg" OR $type == "image/jpeg"){
$photo = imagecreatefromjpeg ("./img/".$foto_name.".".$bestand3);
}elseif($type == "image/x-png"){
$photo = imagecreatefrompng("./img/".$foto_name.".".$bestand3);
}
$photo_dimensions_width = imagesx ($photo);
$photo_dimensions_height = imagesy ($photo);
if ($photo_dimensions_width > $max_thumb OR $photo_dimensoons_height > $max_thumb) {
if ($photo_dimensions_width == $photo_dimensions_height) {
$thumb_dimensions_width = $max_thumb;
$thumb_dimensions_height = $max_thumb;
}
elseif ($photo_dimensions_width > $photo_dimensions_height) {
$value = $photo_dimensions_width / $max_thumb;
$thumb_dimensions_width = $max_thumb;
$thumb_dimensions_height = round ($photo_dimensions_height / $value);
}
else {
$value = $photo_dimensions_height / $max_thumb;
$thumb_dimensions_height = $max_thumb;
$thumb_dimensions_width = round ($photo_dimensions_width / $value);
}
}
else {
$thumb_dimensions_width = $photo_dimensions_width;
$thumb_dimensions_height = $photo_dimensions_height;
}
$create_thumb = imagecreatetruecolor ($thumb_dimensions_width, $thumb_dimensions_height);
imagecopyresampled ($create_thumb, $photo, 0, 0, 0, 0, $thumb_dimensions_width, $thumb_dimensions_height, $photo_dimensions_width, $photo_dimensions_height);
ImageJpeg($create_thumb,'./modulen/fotoboek/thumbs/'.$foto_name.".jpg",90);
Imagedestroy($photo);
//hier zijn de thumbs klaar
if($type == "image/gif"){
$photo = imagecreatefromgif("./img/".$foto_name.".".$bestand3);
}elseif($type == "image/pjpeg" OR $type == "image/jpeg"){
$photo = imagecreatefromjpeg ("./img/".$foto_name.".".$bestand3);
}elseif($type == "image/x-png"){
$photo = imagecreatefrompng("./img/".$foto_name.".".$bestand3);
}
$photo_dimensions_width = imagesx ($photo);
$photo_dimensions_height = imagesy ($photo);
if ($photo_dimensions_width > $max_image OR $photo_dimensoons_height > $max_image) {
if ($photo_dimensions_width == $photo_dimensions_height) {
$thumb_dimensions_width = $max_image;
$thumb_dimensions_height = $max_image;
}
elseif ($photo_dimensions_width > $photo_dimensions_height) {
$value = $photo_dimensions_width / $max_image;
$thumb_dimensions_width = $max_image;
$thumb_dimensions_height = round ($photo_dimensions_height / $value);
}
else {
$value = $photo_dimensions_height / $max_image;
$thumb_dimensions_height = $max_image;
$thumb_dimensions_width = round ($photo_dimensions_width / $value);
}
}
else {
$thumb_dimensions_width = $photo_dimensions_width;
$thumb_dimensions_height = $photo_dimensions_height;
}
$create_thumb = imagecreatetruecolor ($thumb_dimensions_width, $thumb_dimensions_height);
imagecopyresampled ($create_thumb, $photo, 0, 0, 0, 0, $thumb_dimensions_width, $thumb_dimensions_height, $photo_dimensions_width, $photo_dimensions_height);
ImageJpeg($create_thumb,'./modulen/fotoboek/images/'.$foto_name.".jpg",90);
Imagedestroy($photo);
$adres="img/$foto_name.$bestand3";
unlink($adres);
$query="INSERT INTO rens_fotoboek (cat, image)
VALUES ('$cat','$foto_name.$bestand3')";
mysql_query($query) or die(mysql_error());
print "foto is met succes toegevoegd<br> \n";
}else{
echo $_FILES['image']['name'][$i]." kon niet geupload worden.<br \>\n";
}
}
}else{
echo "Ongeldig type: ".$type."<br>\n";
}
}else{
echo "Geen file geselecteerd.<br>\n";
}
}
}
?>
if($go=="uploaden"){
$aantal=count($_FILES['image']['type']);
$i=0;
for($i=0;$i<$aantal;$i++){
$foto_name=rand(1,9999)."_".time();
if(!empty($_FILES['image']['tmp_name'][$i])){
$type= $_FILES['image']['type'][$i];
// Bestands naam opvragen
$bestand2 = explode("\\", $_FILES['image']['name'][$i]);
$laatste = count($bestand2) - 1;
$bestand2 = "$bestand2[$laatste]";
// Extensie van bestand opvragen
$bestand3 = explode(".", $bestand2);
$laatste = count($bestand3) - 1;
$bestand3 = "$bestand3[$laatste]";
$bestand3 = strtolower($bestand3);
for ($tel = 0;$tel < $aantal; $tel++){
if ($bestand3 == $ext[$tel]){
$extfout = "nee";
}
}
if($type == "image/gif" OR $type == "image/pjpeg" OR $type == "image/x-png" OR $type == "image/jpeg"){
if(!empty($max_size) && $_FILES['image']['size'][$i] > $max_size){
echo"Bestand is te groot: ".$_FILES['image']['size'][$i]." / ".$max_size."<br>\n";
}elseif(!isset($extfout)){
}else{
if(move_uploaded_file($_FILES['image']['tmp_name'][$i], "./img/".$foto_name.".".$bestand3)){
// hier is het offciele bestand helemaal klaar
if($type == "image/gif"){
$photo = imagecreatefromgif("./img/".$foto_name.".".$bestand3);
}elseif($type == "image/pjpeg" OR $type == "image/jpeg"){
$photo = imagecreatefromjpeg ("./img/".$foto_name.".".$bestand3);
}elseif($type == "image/x-png"){
$photo = imagecreatefrompng("./img/".$foto_name.".".$bestand3);
}
$photo_dimensions_width = imagesx ($photo);
$photo_dimensions_height = imagesy ($photo);
if ($photo_dimensions_width > $max_thumb OR $photo_dimensoons_height > $max_thumb) {
if ($photo_dimensions_width == $photo_dimensions_height) {
$thumb_dimensions_width = $max_thumb;
$thumb_dimensions_height = $max_thumb;
}
elseif ($photo_dimensions_width > $photo_dimensions_height) {
$value = $photo_dimensions_width / $max_thumb;
$thumb_dimensions_width = $max_thumb;
$thumb_dimensions_height = round ($photo_dimensions_height / $value);
}
else {
$value = $photo_dimensions_height / $max_thumb;
$thumb_dimensions_height = $max_thumb;
$thumb_dimensions_width = round ($photo_dimensions_width / $value);
}
}
else {
$thumb_dimensions_width = $photo_dimensions_width;
$thumb_dimensions_height = $photo_dimensions_height;
}
$create_thumb = imagecreatetruecolor ($thumb_dimensions_width, $thumb_dimensions_height);
imagecopyresampled ($create_thumb, $photo, 0, 0, 0, 0, $thumb_dimensions_width, $thumb_dimensions_height, $photo_dimensions_width, $photo_dimensions_height);
ImageJpeg($create_thumb,'./modulen/fotoboek/thumbs/'.$foto_name.".jpg",90);
Imagedestroy($photo);
//hier zijn de thumbs klaar
if($type == "image/gif"){
$photo = imagecreatefromgif("./img/".$foto_name.".".$bestand3);
}elseif($type == "image/pjpeg" OR $type == "image/jpeg"){
$photo = imagecreatefromjpeg ("./img/".$foto_name.".".$bestand3);
}elseif($type == "image/x-png"){
$photo = imagecreatefrompng("./img/".$foto_name.".".$bestand3);
}
$photo_dimensions_width = imagesx ($photo);
$photo_dimensions_height = imagesy ($photo);
if ($photo_dimensions_width > $max_image OR $photo_dimensoons_height > $max_image) {
if ($photo_dimensions_width == $photo_dimensions_height) {
$thumb_dimensions_width = $max_image;
$thumb_dimensions_height = $max_image;
}
elseif ($photo_dimensions_width > $photo_dimensions_height) {
$value = $photo_dimensions_width / $max_image;
$thumb_dimensions_width = $max_image;
$thumb_dimensions_height = round ($photo_dimensions_height / $value);
}
else {
$value = $photo_dimensions_height / $max_image;
$thumb_dimensions_height = $max_image;
$thumb_dimensions_width = round ($photo_dimensions_width / $value);
}
}
else {
$thumb_dimensions_width = $photo_dimensions_width;
$thumb_dimensions_height = $photo_dimensions_height;
}
$create_thumb = imagecreatetruecolor ($thumb_dimensions_width, $thumb_dimensions_height);
imagecopyresampled ($create_thumb, $photo, 0, 0, 0, 0, $thumb_dimensions_width, $thumb_dimensions_height, $photo_dimensions_width, $photo_dimensions_height);
ImageJpeg($create_thumb,'./modulen/fotoboek/images/'.$foto_name.".jpg",90);
Imagedestroy($photo);
$adres="img/$foto_name.$bestand3";
unlink($adres);
$query="INSERT INTO rens_fotoboek (cat, image)
VALUES ('$cat','$foto_name.$bestand3')";
mysql_query($query) or die(mysql_error());
print "foto is met succes toegevoegd<br> \n";
}else{
echo $_FILES['image']['name'][$i]." kon niet geupload worden.<br \>\n";
}
}
}else{
echo "Ongeldig type: ".$type."<br>\n";
}
}else{
echo "Geen file geselecteerd.<br>\n";
}
}
}
?>
<form name="FormName" action="" method="post">
<input name="go" type="hidden" value="upload">
<INPUT TYPE="file" value="1" NAME="image[1]" \>
<input type="submit" value="Send">
</form>
</body>
</html>
Wat werkt er niet?
Ps Ik heb gd geinstalleerd