ftp_put og imagejpeg.
Hejsa.Efter at jeg har oploadet mit site på webhotel, har jeg en del problemmer, bla. med upload af billeder og thumbs.
Jeg kan ikke finde en måde at få imagejpeg og ftp_put på til at fungere på.
min kode ser sådan ud.
$sql = 'INSERT INTO `'.$tbl_name.'` (`Client`) VALUES (\''.$_SESSION["No"].'\');';
mysql_query($sql) or die ("Fejl i sql");
$newname = mysql_insert_id();
if ($str3 == "image/png") {
$ftype="png";
} else if ($str3 == "image/gif") {
$ftype=".gif";
} else if ($str3 == "image/pjpeg") {
$ftype=".jpg";
} else if ($str3 == "image/wbmp") {
$ftype=".bmp";
}
//move_uploaded_file($_FILES["singlefile"]["tmp_name"], $dist.$newname.$ftype);
ftp_put($ftp,$dist.$newname.$ftype,$_FILES['singlefile']['tmp_name'],FTP_BINARY);
list($width_orig, $height_orig) = getimagesize($_FILES['singlefile']['tmp_name']);
$ratio_orig = $width_orig/$height_orig;
if ($width/$height > $ratio_orig) {
$width = $height*$ratio_orig;
} else {
$height = $width/$ratio_orig;
}
$image_p = imagecreatetruecolor($width, $height);
if ($str3 == "image/png") {
$image = imagecreatefrompng($_FILES['singlefile']['tmp_name']);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
imagepng($image_p,$thdist.$newname.$ftype);
} else if ($str3 == "image/gif") {
$image = imagecreatefromgif($_FILES['singlefile']['tmp_name']);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
imagegif($image_p,$thdist.$newname.$ftype);
} else if ($str3 == "image/pjpeg") {
$image = imagecreatefromjpeg($_FILES['singlefile']['tmp_name']);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
imagejpeg($image_p,$_FILES['tmpimage']);
ftp_put($ftp,$dist.$newname.$ftype,$_FILES['tmpimage'],FTP_BINARY);
} else if ($str3 == "image/wbmp") {
$image = imagecreatefromwbmp($_FILES['singlefile']['tmp_name']);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
imagewbmp($image_p,$thdist.$newname.$ftype);
}
ftp_put($ftp,$dist.$newname.$ftype,$_FILES['singlefile']['tmp_name'],FTP_BINARY);
$sql = 'UPDATE `memberimages` SET `Imagestype` = \''.$newname.$ftype.'\' WHERE Id = \''.$newname.'\';';
//echo $sql;
mysql_query($sql) or die ("Fejl i sql");
ftp_close($ftp);
