niemand komt eruit:-(
Formulier wordt ingevuld.
Bestanden selecteren en plaatsen in array (image[]).
Nu wil ik deze bestanden(bv 5) alle 5 een andere naam geven en uploaden, maar niemand ziet het!!
is iemand die mij hiermee kan helpen:
FORMULIER:
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
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
<?PHP
<center>
<form name="blaat" action="upload.php" method="post" enctype="multipart/form-data">
[code]<?PHP
include('../config.php');
?>
<select name='event'>
<option value="event">event</option>
<?php
$querym = "SELECT * FROM event";
$resultm = mysql_query($querym) or die("Query
mislukt"."$querym");
while($rows = mysql_fetch_assoc($resultm))
{
if ($rows[event_naam] == $_POST[event])
{
echo "<option
value=\"".$rows[event_id]."\"
selected=\"selected\">".$rows[event_naam]."</OPTION>";
} else {
?><option ><a href="form.php?melder"<?"".$rows['event_id']?>">
<? echo $rows['event_naam'].""; ?></a> <? echo "</option>"?><?
}
}
?> </select> <!-- einde van de listbox -->
<br><br>
<input type="file" name="image[]" /><br>
<input type="file" name="image[]" /><br>
<input type="file" name="image[]" /><br>
<input type="file" name="image[]" /><br>
<input type="file" name="image[]" /><br>
<input type="submit" name="send" value="verstuur" />
</form>
</center>
?>
<center>
<form name="blaat" action="upload.php" method="post" enctype="multipart/form-data">
[code]<?PHP
include('../config.php');
?>
<select name='event'>
<option value="event">event</option>
<?php
$querym = "SELECT * FROM event";
$resultm = mysql_query($querym) or die("Query
mislukt"."$querym");
while($rows = mysql_fetch_assoc($resultm))
{
if ($rows[event_naam] == $_POST[event])
{
echo "<option
value=\"".$rows[event_id]."\"
selected=\"selected\">".$rows[event_naam]."</OPTION>";
} else {
?><option ><a href="form.php?melder"<?"".$rows['event_id']?>">
<? echo $rows['event_naam'].""; ?></a> <? echo "</option>"?><?
}
}
?> </select> <!-- einde van de listbox -->
<br><br>
<input type="file" name="image[]" /><br>
<input type="file" name="image[]" /><br>
<input type="file" name="image[]" /><br>
<input type="file" name="image[]" /><br>
<input type="file" name="image[]" /><br>
<input type="submit" name="send" value="verstuur" />
</form>
</center>
?>
UPLOAD.PHP
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
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
<?php
error_reporting(E_ALL);
$eventnaam = $_POST['event'];
$path = $eventnaam; // folder waarin de plaatjes komen
$path_t = $path."_thumb/"; // folder waarin de thumbs komen
$max_w = 640; // maximale breedte plaatje
$max_wt = 120; // maximale breedte thumb
$name = "Picture_"; // naam van het plaatje
$kwaliteit = "85"; // kwaliteit waarmee de JPG bewaard wordt
$maxsize = (300*1024); //1024(1 kb) * 300 = 300 kb
$ii="1";
include('../config.php');
// mkdir($path, 0755);
// mkdir($path_t, 0755);
echo $path;
echo "<br><br>";
WHILE ($ii<=5){
if($_SERVER['REQUEST_METHOD']=='POST'){
// if (isset($_FILES["image"]["name"]) && ($_FILES["image"]["name"]) !== "none"){
$orgnaam = "image$ii";
$file = $_FILES[$orgnaam]["name"]; // filename
$image = $_FILES[$orgnaam]["tmp_name"]; // tmp name
$type = $_FILES[$orgnaam]["type"]; // .ext
$size = $_FILES[$orgnaam]["size"]; // bestands grootte in bytes
echo $file;
echo $image;
echo $type;
echo $size;
echo "<br><br>";
if($size < $maxsize){
//afmetingen
$imageXY = getimagesize($image);
$img_w = $imageXY[0]; //width
$img_h = $imageXY[1]; //height
//resize plaatje
if($img_w > $max_w){
$factor = ($img_w / $max_w);
$newimg_w = $max_w;
$newimg_h = ($img_h / $factor);
}
//resize thumb
if($img_w > $max_wt){
$factor = ($img_w / $max_wt);
$newimg_wt = $max_wt;
$newimg_ht = ($img_h / $factor);
}
$newImg_w = (isset($newimg_w)) ? $newimg_w : $img_w;
$newImg_h = (isset($newimg_h)) ? $newimg_h : $img_h;
$newImg_wt = (isset($newimg_wt)) ? $newimg_wt : $img_w;
$newImg_ht = (isset($newimg_ht)) ? $newimg_ht : $img_h;
//
if($imageXY[2]==2 || $imageXY[2]==3 || $imageXY[2]==6){
//switch bestandstype
$newImg = imagecreatetruecolor($newImg_w, $newImg_h);
$newThumb = imagecreatetruecolor($newImg_wt, $newImg_ht);
switch($imageXY[2]){ //bestandstype
case 2: //jpg
$imgSrc = ImageCreateFromJPEG($image); //?
$imgSrcXY = getimagesize($image);
$imgSrc_w = $imgSrcXY[0];
$imgSrc_h = $imgSrcXY[1];
//filename ophogen
$i = 0;
while (file_exists($path.$name.$i.".jpg")) {
$i = $i + 1;
}
$name = $name.$i.".jpg";
//copy + verwijder tmp img
imagecopyresampled($newImg, $imgSrc, 0, 0, 0, 0, $newImg_w, $newImg_h, $imgSrc_w, $imgSrc_h);
imagecopyresampled($newThumb, $imgSrc, 0, 0, 0, 0, $newImg_wt, $newImg_ht, $imgSrc_w, $imgSrc_h);
imagejpeg($newImg, $path.$name);
imagejpeg($newThumb, $path_t.$name);
imagedestroy($newImg);
imagedestroy($newThumb);
break;
}//switch
}//ext check
else{
$errors[]= "ongeldig bestandstype!";
}
}//if maxsize
else{
$errors[] = "Bestand is te groot, maximaal ".($maxsize/1024);
}
// }//!= none
} //post
$ii++;
}
?>
error_reporting(E_ALL);
$eventnaam = $_POST['event'];
$path = $eventnaam; // folder waarin de plaatjes komen
$path_t = $path."_thumb/"; // folder waarin de thumbs komen
$max_w = 640; // maximale breedte plaatje
$max_wt = 120; // maximale breedte thumb
$name = "Picture_"; // naam van het plaatje
$kwaliteit = "85"; // kwaliteit waarmee de JPG bewaard wordt
$maxsize = (300*1024); //1024(1 kb) * 300 = 300 kb
$ii="1";
include('../config.php');
// mkdir($path, 0755);
// mkdir($path_t, 0755);
echo $path;
echo "<br><br>";
WHILE ($ii<=5){
if($_SERVER['REQUEST_METHOD']=='POST'){
// if (isset($_FILES["image"]["name"]) && ($_FILES["image"]["name"]) !== "none"){
$orgnaam = "image$ii";
$file = $_FILES[$orgnaam]["name"]; // filename
$image = $_FILES[$orgnaam]["tmp_name"]; // tmp name
$type = $_FILES[$orgnaam]["type"]; // .ext
$size = $_FILES[$orgnaam]["size"]; // bestands grootte in bytes
echo $file;
echo $image;
echo $type;
echo $size;
echo "<br><br>";
if($size < $maxsize){
//afmetingen
$imageXY = getimagesize($image);
$img_w = $imageXY[0]; //width
$img_h = $imageXY[1]; //height
//resize plaatje
if($img_w > $max_w){
$factor = ($img_w / $max_w);
$newimg_w = $max_w;
$newimg_h = ($img_h / $factor);
}
//resize thumb
if($img_w > $max_wt){
$factor = ($img_w / $max_wt);
$newimg_wt = $max_wt;
$newimg_ht = ($img_h / $factor);
}
$newImg_w = (isset($newimg_w)) ? $newimg_w : $img_w;
$newImg_h = (isset($newimg_h)) ? $newimg_h : $img_h;
$newImg_wt = (isset($newimg_wt)) ? $newimg_wt : $img_w;
$newImg_ht = (isset($newimg_ht)) ? $newimg_ht : $img_h;
//
if($imageXY[2]==2 || $imageXY[2]==3 || $imageXY[2]==6){
//switch bestandstype
$newImg = imagecreatetruecolor($newImg_w, $newImg_h);
$newThumb = imagecreatetruecolor($newImg_wt, $newImg_ht);
switch($imageXY[2]){ //bestandstype
case 2: //jpg
$imgSrc = ImageCreateFromJPEG($image); //?
$imgSrcXY = getimagesize($image);
$imgSrc_w = $imgSrcXY[0];
$imgSrc_h = $imgSrcXY[1];
//filename ophogen
$i = 0;
while (file_exists($path.$name.$i.".jpg")) {
$i = $i + 1;
}
$name = $name.$i.".jpg";
//copy + verwijder tmp img
imagecopyresampled($newImg, $imgSrc, 0, 0, 0, 0, $newImg_w, $newImg_h, $imgSrc_w, $imgSrc_h);
imagecopyresampled($newThumb, $imgSrc, 0, 0, 0, 0, $newImg_wt, $newImg_ht, $imgSrc_w, $imgSrc_h);
imagejpeg($newImg, $path.$name);
imagejpeg($newThumb, $path_t.$name);
imagedestroy($newImg);
imagedestroy($newThumb);
break;
}//switch
}//ext check
else{
$errors[]= "ongeldig bestandstype!";
}
}//if maxsize
else{
$errors[] = "Bestand is te groot, maximaal ".($maxsize/1024);
}
// }//!= none
} //post
$ii++;
}
?>
Niemand??? :'(
de foutmelding is dat ie niets optelt, maar dit:
bv 3 bestanden:
naam_0.jpg
naam_0.jpg0.jpg
naam_0.jpg0.jpg0.jpg
ipv:
naam_0.jpg
naam_1.jpg
naam_2.jpg
->
$name = $name.$i;
het gaat me niet om de foutmelding unable to open, maar om de 00, 000, 0000
Foto35.jpg/tmp/phpXCswYyimage/pjpeg56706
Warning: imagejpeg(): Unable to open 'Beerse_(The Saloon)_thumb/Picture_0' for writing in /var/www/vhosts/phphulp.nl/httpdocs/upload/upload.php on line 77
Foto22.jpg/tmp/phpsmZIUVimage/pjpeg67371
Warning: imagejpeg(): Unable to open 'Beerse_(The Saloon)_thumb/Picture_00' for writing in /var/www/vhosts/phphulp.nl/httpdocs/upload/upload.php on line 77
Foto17.jpg/tmp/php9lUd7kimage/pjpeg76225
Warning: imagejpeg(): Unable to open 'Beerse_(The Saloon)_thumb/Picture_000' for writing in /var/www/vhosts/phphulp.nl/httpdocs/upload/upload.php on line 77
Foto32.jpg/tmp/phpr2LyVMimage/pjpeg47421
Warning: imagejpeg(): Unable to open 'Beerse_(The Saloon)_thumb/Picture_0000' for writing in /var/www/vhosts/phphulp.nl/httpdocs/upload/upload.php on line 77
$namehlp = $name.$i.".jpg"; en dan verder werken met $namehlp zodat de originele $name niet veranderd.
Edit: Typo
Gewijzigd op 06/04/2005 14:36:00 door - SanThe -
maar dat heeft toch niets te maken met die 0 die er steeds bij komt?
Edit: Mag eigenlijk nix uitmaken, maar je weet nooit.
Gewijzigd op 06/04/2005 14:49:00 door - SanThe -
topper zeg! Eindelijk!!!
Thanx.
neem maar een biertje van me!!
Groeten
Franko
Frank:
neem maar een biertje van me!!
Doe ik.......