| Autor | Zpráva | ||
|---|---|---|---|
| pitomec Profil |
#1 · Zasláno: 29. 12. 2007, 16:44:24
ahoj, mam tento skript ktery oddelene funguje bez problemu (jsou dve casti, prvni rozbali obrazek a druhy kazdej upravi a ulozi) ale spolu hlasi:
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 8192 bytes) in.... nektery obrazky to prijme (neni to velikosti souboru toho obrazku ani zipu, 30MB to vezme, 4MB ne)
$auto = strip_tags(AddSlashes($_POST['auto']));
$yuo = explode('.',$_FILES["zip"]["name"]);
if (is_uploaded_file($_FILES["zip"]["tmp_name"])):
$zip = zip_open($_FILES["zip"]["tmp_name"]);
if ($zip) {
while ($zip_entry = zip_read($zip)) {
$sql_num = mysql_num_rows(mysql_query("SELECT * FROM `fotky` WHERE `id_auta`='$auto'"))+1;
if (zip_entry_open($zip, $zip_entry, "r")) {
$jmeno =explode(".",zip_entry_name($zip_entry));
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
$file = fopen ("../fotky/".$auto."-0".$sql_num.".".$jmeno[1]."", "w+");
$file = fwrite($file,$buf);
$insert_foto = mysql_query("INSERT INTO `fotky` VALUES('0','".$auto."','".$auto."-0".$sql_num.".".$jmeno[1]."','0')");
$filename = "../fotky/".$auto."-0".$sql_num.".".$jmeno[1]."";
// Set a maximum height and width
$width = 640;
$height = 480;
// Content type
if($jmeno[1] == 'jpg' OR $jmeno[1] == 'jpeg' OR $jmeno[1] == 'JPG' OR $jmeno[1] == 'JPEG'){
$action='imagecreatefromjpeg';
}
if($jmeno[1] == 'png'){
$action='imagecreatefrompng';
}
if($jmeno[1] == 'gif'){
$action='imagecreatefromgif';
}
// Get new dimensions
list($width_orig, $height_orig) = getimagesize($filename);
if(($width_orig > $width) OR ($height_orig > $height)):
if ($width && ($width_orig < $height_orig)) {
$width = ($height / $height_orig) * $width_orig;
} else {
$height = ($width / $width_orig) * $height_orig;
}
else:
$width = $width_orig;
$height = $height_orig;
endif;
// Resample
$image_p = imagecreatetruecolor($width, $height);
$image = $action($filename);
$imagenew=imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
// Output
if($jmeno[1] == 'jpg' OR $jmeno[1] == 'jpeg' OR $jmeno[1] == 'JPG' OR $jmeno[1] == 'JPEG'){
$output='imagejpeg';
}
if($jmeno[1] == 'png' OR $jmeno[1] == 'PNG'){
$output='imagepng';
}
if($jmeno[1] == 'gif' OR $jmeno[1] == 'GIF'){
$output='imagegif';
}
$imagenew =$output($image_p, $filename, 100);
zip_entry_close($zip_entry);
}
}
zip_close($zip);
vsem moc dekuji... |
||
| djlj Profil |
#2 · Zasláno: 30. 12. 2007, 00:02:30
pitomče, mohlo by pomoct po každém zmenšení obrázku jej vymazat z paměti pomocí funkce unset.
|
||
|
Časová prodleva: 19 let
|
|||
0