nalaganje slike vrne črno sliko
1 naročnik
1 naročnik
Pozdravljeni!
Zanima me, zakaj mi skripta, vrne(naloži) črno sliko. Vse se je zgodilo, ko je bila stran preseljena iz enega serverja na drugega. Sliko pomanjša, preimenuje.. vse vredu a slika je črna. Skripta:
$maxsize = 1024 * 768;
$filetypes = array ("image/jpeg", "image/pjpeg", "image/png", "image/x-png", "image/gif");
for ($i = 0; $i < count ($_FILES['fajl']['name']); $i++) {
$filename = $_FILES['fajl']['name'][$i];
$filesize = $_FILES['fajl']['size'][$i];
$filetype = $_FILES['fajl']['type'][$i];
$filetemp = $_FILES['fajl']['tmp_name'][$i];
if ($filename != "") {
if ($filesize > $maxsize) {
unlink($filetemp);
$result = false;
$fileimgx = 3;
} else {
if (!in_array($filetype, $filetypes)) {
unlink($filetemp);
$result = false;
$fileimgx = 4;
} else {
switch ($filetype) {
case $filetypes[0]:
case $filetypes[1]:
$fileimgx = word().".jpg";
move_uploaded_file($filetemp, BASEDIR.$fileimgx);
imagejpeg(thumb(imagecreatefromjpeg(BASEDIR.$fileimgx)), IMAGES.$fileimgx);
break;
case $filetypes[2]:
case $filetypes[3]:
$fileimgx = word().".png";
move_uploaded_file($filetemp, BASEDIR.$fileimgx);
imagejpeg(thumb(imagecreatefrompng(BASEDIR.$fileimgx)), IMAGES.$fileimgx);
break;
case $filetypes[4]:
$fileimgx = word().".gif";
move_uploaded_file($filetemp, BASEDIR.$fileimgx);
imagejpeg(thumb(imagecreatefromgif(BASEDIR.$fileimgx)), IMAGES.$fileimgx);
break;
}
}
}
}
}
@unlink(BASEDIR.$fileimgx);
Funkciji:
function word() {
$length = 6;
$pattern = "1234567890abcdefghijklmnopqrstuvwxyz";
for ($i = 0; $i < $length; $i++) {
if (isset ($key)) $key .= $pattern{rand (0, 35)};
else $key = $pattern{rand (0, 35)};
}
return $key;
}
function thumb($img) {
$w = 50; $h = 50;
$copy = imagecreatetruecolor ($w, $h);
imagecopyresampled ($copy, $img, 0, 0, 0, 0, $w, $h, imagesx ($img), imagesy ($img));
imagedestroy ($img);
return $copy;
}
Hvala za odgovore!