PNG bestand wordt niet laten zien
Ik vraag mij af hoe ik een PNG bestand kan opslaan. Het bestand wordt keurig geupload maar niet getoond. Ik gebruik hiervoor onderstaand script. Wat doe ik verkeerd?
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
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
<?php
$target = PATH;
$temp = $target . basename($_FILES['foto']['name'][$i]);
$fileName = $_FILES['foto']['name'][$i];
$fileType = $_FILES['foto']['type'][$i];
$fileSize = $_FILES['foto']['size'][$i];
move_uploaded_file($_FILES['foto']['tmp_name'][$i], $temp);
$thumb_quality = 80;
$thumb_width = 600;
list($width, $height, $type, $attr) = getimagesize($target . $_FILES['foto']['name'][$i]);
if($width > $thumb_width) {
if($fileType == "image/png") {
header('Content-Type: image/png');
$image_handle=imagecreatefrompng($temp);
imagealphablending($image_handle, false);
imagesavealpha($image_handle, true);
}
$thumb_height = round(($thumb_width / $width) * $height);
$thumbnail = imagecreatetruecolor($thumb_width, $thumb_height)
or $thumbnail = imagecreate($thumb_width, $thumb_height);
imagecopyresampled($thumbnail, $image_handle, 0, 0, 0, 0, $thumb_width, $thumb_height, $width, $height);
// Output image
if($fileType == "image/png") {
imagepng($thumbnail, $temp, $thumb_quality);
}
imagedestroy($image_handle);
imagedestroy($thumbnail);
}
?>
$target = PATH;
$temp = $target . basename($_FILES['foto']['name'][$i]);
$fileName = $_FILES['foto']['name'][$i];
$fileType = $_FILES['foto']['type'][$i];
$fileSize = $_FILES['foto']['size'][$i];
move_uploaded_file($_FILES['foto']['tmp_name'][$i], $temp);
$thumb_quality = 80;
$thumb_width = 600;
list($width, $height, $type, $attr) = getimagesize($target . $_FILES['foto']['name'][$i]);
if($width > $thumb_width) {
if($fileType == "image/png") {
header('Content-Type: image/png');
$image_handle=imagecreatefrompng($temp);
imagealphablending($image_handle, false);
imagesavealpha($image_handle, true);
}
$thumb_height = round(($thumb_width / $width) * $height);
$thumbnail = imagecreatetruecolor($thumb_width, $thumb_height)
or $thumbnail = imagecreate($thumb_width, $thumb_height);
imagecopyresampled($thumbnail, $image_handle, 0, 0, 0, 0, $thumb_width, $thumb_height, $width, $height);
// Output image
if($fileType == "image/png") {
imagepng($thumbnail, $temp, $thumb_quality);
}
imagedestroy($image_handle);
imagedestroy($thumbnail);
}
?>
Gewijzigd op 09/08/2010 11:39:33 door Mark Zwerwer
Gesponsorde koppelingen:
Er zijn nog geen reacties op dit bericht.


