Autor | Zpráva | ||
---|---|---|---|
LUK Profil * |
#1 · Zasláno: 30. 12. 2011, 21:46:14
Ahoj, mám menší problém se scriptem na upload fotek. Na jednom serveru mě script bez problému chodí, ale na druhém ne. :-( Myslím si, že to má co dočinění s novou verzí php. Nejsem zrovna moc zkušený, co se týče php, proto bych Vás chtěl poprosit, zdali by jste mi mohli pradit, jak mám následující script opravit, aby fungoval i pod novější verzí php. Předem moc děkuji.
if (is_uploaded_file($soubor))://pokud jiz byl proveden upload $cesta="./data/"; //nami definovana cesta function image_shrink($file_in, $file_out, $max_x, $max_y = 0) { $imagesize = getimagesize($file_in); if ((!$max_x && !$max_y) || !$imagesize[0] || !$imagesize[1]) { return false; } switch ($imagesize[2]) { case 1: $img = imagecreatefromgif($file_in); break; case 2: $img = imagecreatefromjpeg($file_in); break; case 3: $img = imagecreatefrompng($file_in); break; default: return false; } if (!$img) { return false; } if ($max_x) { $width = $max_x; $height = round($imagesize[1] * $width / $imagesize[0]); } if ($max_y && (!$max_x || $height > $max_y)) { $height = $max_y; $width = round($imagesize[0] * $height / $imagesize[1]); } $img2 = imagecreatetruecolor($width, $height); imagecopyresampled($img2, $img, 0, 0, 0, 0, $width, $height, $imagesize[0], $imagesize[1]); if ($imagesize[2] == 2) { return imagejpeg($img2, $file_out); } elseif ($imagesize[2] == 1 && function_exists("imagegif")) { imagetruecolortopalette($img2, false, 256); return imagegif($img2, $file_out); } else { return imagepng($img2, $file_out); } move_uploaded_file ($file_out, $cesta.$file_out_name); } $query12b="select MAX(id) from ".$MySQL_matrace.""; $result12b = mysql_query($query12b) or die(mysql_error()); $row12b = mysql_fetch_array($result12b); $nazev="foto".$row12b['MAX(id)']."-mini.jpg"; image_shrink($soubor, $cesta.$nazev, 95, 71); $nazev2="foto".$row12b['MAX(id)'].".jpg"; image_shrink($soubor, $cesta.$nazev2, 750, 563); endif; |
||
Alphard Profil |
#2 · Zasláno: 30. 12. 2011, 21:58:39
První podezřelý je Regsiter globals.
Pokud to není tím, vypisují se nějaké chyby? |
||
LUK Profil * |
#3 · Zasláno: 30. 12. 2011, 23:56:42
Díky za popostrčení... Nějaké úpravy jsem již provedl, ale nevím jak dál. :-/ Php už žádný chybový hlášky nevypisuje. Myslím si, že bude ještě problém v
$imagesize = getimagesize($file_in); Díky za další rady a postřehy.
if (is_uploaded_file($_FILES['soubor']['tmp_name']))://pokud jiz byl proveden upload $cesta="./data/"; //nami definovana cesta function image_shrink($file_in, $file_out, $max_x, $max_y = 0) { $imagesize = getimagesize($file_in); if ((!$max_x && !$max_y) || !$imagesize[0] || !$imagesize[1]) { return false; } switch ($imagesize[2]) { case 1: $img = imagecreatefromgif($file_in); break; case 2: $img = imagecreatefromjpeg($file_in); break; case 3: $img = imagecreatefrompng($file_in); break; default: return false; } if (!$img) { return false; } if ($max_x) { $width = $max_x; $height = round($imagesize[1] * $width / $imagesize[0]); } if ($max_y && (!$max_x || $height > $max_y)) { $height = $max_y; $width = round($imagesize[0] * $height / $imagesize[1]); } $img2 = imagecreatetruecolor($width, $height); imagecopyresampled($img2, $img, 0, 0, 0, 0, $width, $height, $imagesize[0], $imagesize[1]); if ($imagesize[2] == 2) { return imagejpeg($img2, $file_out); } elseif ($imagesize[2] == 1 && function_exists("imagegif")) { imagetruecolortopalette($img2, false, 256); return imagegif($img2, $file_out); } else { return imagepng($img2, $file_out); } move_uploaded_file ($file_out, $cesta.$file_out_name); } $query12b="select MAX(id) from ".$MySQL_fotogalerie.""; $result12b = mysql_query($query12b) or die(mysql_error()); $row12b = mysql_fetch_array($result12b); $soubor = $_FILES['soubor']['tmp_name']; $nazev="foto".$row12b['MAX(id)']."-mini.jpg"; image_shrink($soubor, $cesta.$nazev, 95, 71); $nazev2="foto".$row12b['MAX(id)'].".jpg"; image_shrink($soubor, $cesta.$nazev2, 750, 563); endif; |
||
nethor Profil |
#4 · Zasláno: 31. 12. 2011, 02:40:40
1) Asi by pomohlo těm, kdo Ti chtejí pomoci, kdybys napsal, co máš za verzi PHP
2) Zkontroluj, jestli se vypisují vůbec někdy nějaké chybové hlášky (zapnutí error report) 3) Zkus si postupně nechat vypisovat hodnoty proměnných , příp, návratové hodnoty funkce - přes echo nebo var_dump(). Takhle by to mělo jít vystopovat. |
||
LUK Profil * |
#5 · Zasláno: 1. 1. 2012, 23:04:35
Verze php je 5.3.3-7+squeeze3. Žádně chybové hlášky se nevypisují (mám je zapnutý pomocí
ini_set('display_errors', TRUE); error_reporting(E_ALL); |
||
Časová prodleva: 12 let
|
0