Hee mensen,
Ik ben bezig met een scripje waarmee een foto geupload kan worden naar het database en dir.
De foto wordt met het uploaden verkleint en in een map geplaatst en er wordt een thumbnail van gemaakt die ook in een andere map geplaatst wordt. De dir adres wordt in db opgeslagen.
Dat wegschijven naar database gaat perfect, alleen krijg ik (veel) errors bij het wegschrijven naar dirs.
Gister had ik er met iemand anders naar gekeken, en dit kreeg hij voor elaar. Wie kan me verder helpen?
Dit is het script
En dit zijn de errors
Warning: getimagesize(images/data/vissen/38.jpg): failed to open stream: No such file or directory in /home/aquanl/public_html/admin_vis1.php on line 482
»»» Line 482 = $afbeeldinginfo = getimagesize($foto);
Warning: imagecreatefromjpeg(images/data/vissen/38.jpg): failed to open stream: No such file or directory in /home/aquanl/public_html/admin_vis1.php on line 515
»»» Line 515 = $old_thumbnail = imagecreatefromjpeg($foto);
Warning: imagecreatetruecolor(): Invalid image dimensions in /home/aquanl/public_html/admin_vis1.php on line 518
»»» Line 518 = $new_thumbnail = imagecreatetruecolor($newthumb_b, $newthumb_h);
Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/aquanl/public_html/admin_vis1.php on line 521
»»» Line 521 = imagecopyresampled($new_thumbnail, $old_thumbnail, 0, 0, 0, 0, $newthumb_b, $newthumb_h, $orgfoto_b, $orgfoto_h);
Warning: imagejpeg(): supplied argument is not a valid Image resource in /home/aquanl/public_html/admin_vis1.php on line 524
»»» Line 524 = imagejpeg($new_thumbnail, $thumb);
Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/aquanl/public_html/admin_vis1.php on line 527
»»» Line 527 = imagedestroy($old_thumbnail);
Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/aquanl/public_html/admin_vis1.php on line 528
»»» Line 528 = imagedestroy($new_thumbnail);
Wie kan me helpen?
Ik ben bezig met een scripje waarmee een foto geupload kan worden naar het database en dir.
De foto wordt met het uploaden verkleint en in een map geplaatst en er wordt een thumbnail van gemaakt die ook in een andere map geplaatst wordt. De dir adres wordt in db opgeslagen.
Dat wegschijven naar database gaat perfect, alleen krijg ik (veel) errors bij het wegschrijven naar dirs.
Gister had ik er met iemand anders naar gekeken, en dit kreeg hij voor elaar. Wie kan me verder helpen?
Dit is het script
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
| <? } elseif($actie == "upload") { $aquawish_id = $_GET["aquawish_id"]; $query = "SELECT * FROM admin_aquawish WHERE aquawish_id = $aquawish_id"; $query = mysql_query($query); //or die(mysql_error()); $row = mysql_fetch_assoc($query); ?> <? // $foto => locatie + naam van de foto // $thumb => locatie + naam van de thumbnail // $maxthumb_b => maximale breedte thumbnail // $maxthumb_b => maximale hoogte thumbnail function CreateThumbnail($foto, $thumb, $maxthumb_b, $maxthumb_h) { // Krijg informatie over afbeelding $afbeeldinginfo = getimagesize($foto); $orgfoto_b = $afbeeldinginfo[0]; $orgfoto_h = $afbeeldinginfo[1]; // Afbeelding aanpassen (resize) if($orgfoto_b > $maxthumb_b || $orgfoto_h > $maxthumb_h) { // bepaal de factoren if($orgfoto_b / $orgfoto_h > $maxthumb_b / $maxthumb_h) { // newfoto_b > maxthumb_b is de breedte bepalend $newthumb_b = $maxthumb_b; // hoogte berekenen $factor = $orgfoto_b / $maxthumb_b; $newthumb_h = round($orgfoto_h / $factor); } else { // newfoto_h > maxthumb_h is de hoogte bepalend $newthumb_h = $maxthumb_h; // breedte berekenen $factor = $orgfoto_h / $maxthumb_h; $newthumb_b = round($orgfoto_b / $factor); } } else { // het past $newthumb_b = $orgfoto_b; $newthumb_h = $orgfoto_h; } // open afbeelding $old_thumbnail = imagecreatefromjpeg($foto); // maak een tijdelijke afbeelding met nieuwe b en h $new_thumbnail = imagecreatetruecolor($newthumb_b, $newthumb_h); // maak een nieuwe afbeedling imagecopyresampled($new_thumbnail, $old_thumbnail, 0, 0, 0, 0, $newthumb_b, $newthumb_h, $orgfoto_b, $orgfoto_h); // opslaan imagejpeg($new_thumbnail, $thumb); // opschonen geheugen imagedestroy($old_thumbnail); imagedestroy($new_thumbnail); } ?> <div align="center"> <br/> <table class="content" cellpading="0" cellspacing="0"> <tr> <td> <span class="titel">Aquawish vissen upload pagina</span><br/> U bevindt zich nu op het foto upload gedeelte van aquawish. Hier kunt u foto's van de <? echo $row[aquawish_naam]; ?> uploaden. vergeet niet de zogenaamde alt beschrijving in te vullen. </td> </tr> </table> <br/> <form method=post action="?p=admin_vis1&actie=upload&aquawish_id=<? echo $row[aquawish_id]; ?>" enctype="multipart/form-data"> <table class="content" cellpading="0" cellspacing="0"> <tr> <td class="contenttitelborder1" colspan="2">foto toevoegen aan de <? echo $row[aquawish_naam]; ?>/<? echo $row[aquawish_latnaam]; ?>:</td> </tr> <tr> <td class="contenttitelborder2">foto:</td> <td class="contenttitelborder3"><input type="file" size="50" name="file"></td> </tr> <tr> <td class="contenttitelborder2">Alt texst:</td> <td class="contenttitelborder3"><input type="text" size="50" name="foto_alt"><input type="hidden" size="5" name="foto_id2" value="<? echo $row[aquawish_id]; ?>"><input type="hidden" size="5" name="foto_soortfoto" value="<? echo $row[aquawish_soortreactie]; ?>"><input type="hidden" size="5" name="foto_soort" value="<? echo $row[aquawish_naam]; ?>/<? echo $row[aquawish_latnaam]; ?>"></td> </tr> <tr> <td class="contenttitelborder3" colspan="2" align="center"><input type="submit" name="upload" value="upload"></td> </tr> </table> </form> <?php if($_FILES['file']['name']) { //hieronder verranderen $pad = "images/data/vissen/"; //geef map in je ftp chmod: 777 $thumbnailpad = "images/data/vissen/thumb/"; $nieuwnaam = $row['aquawish_id']; //Dit wordt de nieuwe naam, verrander het $max_breedte = "350"; //De maximale breedte die de avatar mag hebben $max_hoogte = "263"; //De maximale hoogte die de avatar mag hebben $min_breedte = "5"; //De minimale breedte die de avatar mag hebben $min_hoogte = "5"; //De minimale hoogte die de avatar mag hebben $max_bytes = 307200; //Hoeveel aantal bytes de avatar maximaal mag hebben //hierboven verranderen $extensie = explode(".", $_FILES['file']['name']); $extensie = strtolower(end($extensie)); $naam = "$nieuwnaam.$extensie"; $foto ="$pad$naam"; $thumbnail ="$thumbnailpad$naam"; $groote = getimagesize($_FILES['file']['tmp_name']); if(strtoupper($extensie) != "GIF" && strtoupper($extensie) != "JPG" && strtoupper($extensie) != "JPEG" && strtoupper($extensie) != "PNG") { echo "<h6>Uploaden mislukt</h6><br>"; echo "Je kan alleen .gif, .jpg & .png bestanden uploaden!<br><br><a href='javascript:history.back(1)'>Probeer opnieuw.</a>"; } elseif($groote[0] > $max_breedte || $groote[1] > $max_hoogte || $groote[0] < $min_breedte || $groote[1] < $min_hoogte) { echo "<h6>Uploaden mislukt</h6><br>"; echo "De breedte of hoogte van je afbeelding is groter dan $max_breedte pixels of kleiner dan $min_breedte pixels.<br><br><a href='javascript:history.back(1)'>Probeer opnieuw.</a>"; } elseif(filesize($file) > $max_bytes) { echo "<h6>Uploaden mislukt</h6><br>"; echo "Het bestand is groter dan$max_bytes bytes.<br><br><a href='javascript:history.back(1)'>Probeer opnieuw.</a>"; } CreateThumbnail($foto, $thumbnailpad . $foto, 106, 80); } ?> <? if( isset($_POST["upload"])) { if($_POST["foto_alt"] != "") { $telgb = mysql_query("SELECT file FROM admin_foto WHERE file='$foto'") or die($error[1]); $numgb = mysql_num_rows($telgb); if($numgb == "1") { echo"<div class='warning' align='center'>Deze foto bestaat al, je kan eventueel een andere foto toevoegen</div>"; } else { echo"<center>De foto is toegevoegd.</center>"; mysql_query("INSERT INTO admin_foto (foto_poster,file,foto_thumb,foto_alt,foto_id2,foto_soortfoto,foto_soort,foto_datum) values ('".$_COOKIE["login"]."','$foto','$thumbnail','".$_POST["foto_alt"]."','".$_POST["foto_id2"]."','".$_POST["foto_soortfoto"]."','".$_POST["foto_soort"]."','".$datum."')") or die(mysql_error()); } } else { echo "<div class='warning' align='center'>U heeft iets niet ingevult.</div>"; } } ?> |
En dit zijn de errors
Warning: getimagesize(images/data/vissen/38.jpg): failed to open stream: No such file or directory in /home/aquanl/public_html/admin_vis1.php on line 482
»»» Line 482 = $afbeeldinginfo = getimagesize($foto);
Warning: imagecreatefromjpeg(images/data/vissen/38.jpg): failed to open stream: No such file or directory in /home/aquanl/public_html/admin_vis1.php on line 515
»»» Line 515 = $old_thumbnail = imagecreatefromjpeg($foto);
Warning: imagecreatetruecolor(): Invalid image dimensions in /home/aquanl/public_html/admin_vis1.php on line 518
»»» Line 518 = $new_thumbnail = imagecreatetruecolor($newthumb_b, $newthumb_h);
Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/aquanl/public_html/admin_vis1.php on line 521
»»» Line 521 = imagecopyresampled($new_thumbnail, $old_thumbnail, 0, 0, 0, 0, $newthumb_b, $newthumb_h, $orgfoto_b, $orgfoto_h);
Warning: imagejpeg(): supplied argument is not a valid Image resource in /home/aquanl/public_html/admin_vis1.php on line 524
»»» Line 524 = imagejpeg($new_thumbnail, $thumb);
Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/aquanl/public_html/admin_vis1.php on line 527
»»» Line 527 = imagedestroy($old_thumbnail);
Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/aquanl/public_html/admin_vis1.php on line 528
»»» Line 528 = imagedestroy($new_thumbnail);
Wie kan me helpen?