Includujem subor upload.php, ktoreho kod je:
Kód:
<?php
$uploadedfile = $_FILES['uploadfile']['tmp_name'];
$id=$_GET['id'];
$src = imagecreatefromjpeg($uploadedfile);
list($width,$height)=getimagesize($uploadedfile);
$newwidth=120;
$newheight=50;
if ($width>$newwidth || $height>$newheight)
{
if ($width>120)
{
$newwidth=120;
$newheight=($height/$width)*120;
$tmp=imagecreatetruecolor($newwidth,$newheight);
}
if ($height>50)
{
$newheight=50;
$newwidth=($width/$height)*50;
$tmp=imagecreatetruecolor($newwidth,$newheight);
}
}
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
$ext = explode('.',$_FILES['uploadfile']['name']);
$ext = $ext[count($ext)-1];
$filename = "imgs/".$id.".".$ext;
imagejpeg($tmp,$filename,100);
imagedestroy($src);
imagedestroy($tmp);
?>
subor ma upravit velkost, premenovat a nakoniec ulozit obrazok. no nejako mi to nefunguje, pretoze mi to vzdy vyhodi chybu na riadkoch, ktore sa zacinaju na imagecopyresampled, imagejpeg, imagedestroy (2x).
Chyba je vzdy:
Citácia:
supplied argument is not a valid Image resource
kde moze byt chyba?
DIK.