<?
require"../../../redit/protection.php";
session_start();
ob_start();
if ($file<>"") {
$rest=strrchr($file_name,".");
$rest=substr($rest,1);
if (($rest=="JPG") or ($rest=="jpg") or ($rest=="jpeg") or ($rest=="JPEG")) {
function kopiruj($cesta,$file,$soubor,$tn,$width,$height,$truecolor) {
$gd=$truecolor;
if ($tn=='n') {
} else {
if (empty($width)) $width=120;
if (empty($height)) $height=80;
$max_width=$width;
$max_height=$height;
$size=GetImageSize($file);
$width=$size[0];
$height=$size[1];
$x_ratio=$max_width/$width;
$y_ratio=$max_height/$height;
if (($width<=$max_width) && ($height<=$max_height)) {
$tn_width=$width;
$tn_height=$height;
} else
if (($x_ratio*$height)<$max_height) {
$tn_height=ceil($x_ratio*$height);
$tn_width=$max_width;
} else {
$tn_width=ceil($y_ratio*$width);
$tn_height=$max_height;
}
$src=imagecreatefromjpeg($file);
if ($gd=='n') {
$dst=imagecreate($tn_width,$tn_height);
ImageCopyResized($dst,$src,0,0,0,0,$tn_width,$tn_height,$width,$height);
} else {
$dst=imagecreatetruecolor($tn_width,$tn_height);
ImageCopyResampled($dst,$src,0,0,0,0,$tn_width,$tn_height,$width,$height);
}
$file_name_small=$cesta."/".$soubor;
ImageJPEG($dst,$file_name_small,75);
chmod($file_name_small,0777);
ImageDestroy($src);ImageDestroy($dst);
}
}
if (!empty($file)) {
include("spojenie.php");
$vysledok8=MySQL_Query("SELECT id FROM ".$_SESSION["lang"]."clanky where nazov='$nnn'",$conn1);
$radek8=mysql_fetch_array($vysledok8);
$id3=$radek8[id];
$nazov1="$id3".".jpg";
kopiruj("clanky",$file,$nazov1,'y','120','80','y');
$vydek=mysql_query("update ".$_SESSION["lang"]."clanky set obrazok='clanky/$nazov1' where nazov='$nnn'",$conn1) or die("Chyba pri vkladani obrazku");
}
} else {
echo"Obrázok musí by5 typu: <b>jpg</b>";
}
}else {}
ob_end_flush();
?>
Toto je kód na skopírovanie obrázka z klienta na server. PHP interpreter vyhodí chybu na príkaze $src=imagecreatefromjpeg($file);. Je imagecreatefromjpeg nejaký zlý príkaz alebo nový a na serveri beží staré PHP? Používam EasyPHP 1.8, ale nefunguje to ani na Internete. Tam netuším o akú verziu PHP sa jedná. Viete mi poradiť iný vhodnejší kód na kopírovanie na server. Kód som nevytvoril ja, len ho potrebujem spojazdniť. Vraj to funguje na jednej stránke.