akuterrer Posted August 19, 2008 Share Posted August 19, 2008 Hi everyone, I'm a newbie with PHP and has very little PHP coding knowledge. I'm creating a photo gallery and had stumbled on this PHP code from http://www.web-album.org/en Thing is, when I'm trying to import a large sized photo, it gives out an error message :- Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 9216 bytes) in /www/vndv.com/a/k/u/akuterrer/htdocs/WebALBUM/inc/inc_images.php on line 31 This is the code on the file inc_images.php. <?php ######################################################################## # # # WEBalbum # # www.web-album.org # # version: 2.0 EN # # Copyright (C) 2004-2005 duda # # # # WEBalbum is a freeware. # # You can install and use it without any changes # # for free and no limits. # # # ######################################################################## function Image_resize($filename, $new_w=200, $new_h=200, $compression=50, $postfix='', $rotate=0) { if(!@$size=getimagesize($filename)) return false; $ratio=$size[0]/$size[1]; if ($ratio>=1) $new_h=round($new_w/$ratio); else $new_w=round($new_h*$ratio); if ($size[0]<$new_w && $size[1]<$new_h) { $new_w=$size[0]; $new_h=$size[1]; } $src_img=ImageCreateFromJpeg($filename); $rotate_deg=0; if ($rotate==1) {$rotate_deg=270;$new_w=$size[1];$new_h=$size[0];} if ($rotate==2) $rotate_deg=180; if ($rotate==3) {$rotate_deg=90;$new_w=$size[1];$new_h=$size[0];} if($rotate_deg) { $src_img = imagerotate($src_img, $rotate_deg, 0); } $dst_img=imagecreatetruecolor($new_w,$new_h); imagecopyresampled($dst_img,$src_img,0,0,0,0,$new_w,$new_h,ImageSX($src_img),ImageSY($src_img)); $filename_new=$filename.$postfix; ImageJpeg($dst_img,$filename_new,$compression); ImageDestroy($dst_img); return true; } function Photo_add ($file, $name, $desc, $author, $login, $id_cat, $date_public=1, $rotate=0) { global $USER_PRIV,$LA,$resize_mode; $form_file='photo_file'; $error=0; $name=addslashes_d($name); $desc=addslashes_d($desc); $author=addslashes_d($author); $date_add=date('Y-m-d H:i:s'); $date_public=($date_public==1) ? date('Y-m-d H:i:s') : '0000-00-00 00:00:00'; $hash=md5(microtime()); if (isset($_FILES[$form_file]) && !$file) { $error=$_FILES[$form_file]["error"]; $file_type=$_FILES[$form_file]["type"]; if ($file_type!='image/jpeg' && $file_type!='image/pjpeg') $error=5; if ($error==0) { $file_size=$_FILES[$form_file]["size"]; $file_name=$_FILES[$form_file]["name"]; if (!@move_uploaded_file($_FILES[$form_file]["tmp_name"], SYSTEM_PHOTOS_DIRECTORY.'/'.$hash)) $error=6; } } elseif(preg_match("/^(http:\/\/).*/i",$file)) { $file=str_replace('http://','',$file); $slash=strpos($file,'/'); $host=substr($file,0,$slash); $path=substr($file,$slash); $file_url = @fsockopen($host, 80, $errno, $errstr, 5); $file_=''; if ($file_url) { $out = "GET ".$path." HTTP/1.1\r\n"; $out .= "Host: ".$host."\r\n"; $out .= "Connection: Close\r\n\r\n"; fwrite($file_url, $out); $body = false; while (!feof($file_url)) { $s = fgets($file_url, 32768); if ( $body ) $file_.= $s; if ( $s == "\r\n" ) $body = true; } fclose ($file_url); $file_name=substr($file,strrpos($file,'/')+1); $file_type='image/jpeg'; if (!$file_ || (eregi("Not Found", $file_))) $error=8; if(!$file2=fopen(SYSTEM_PHOTOS_DIRECTORY.'/'.$hash, 'w')) $error=6; fwrite($file2, $file_); fclose ($file2); if(!@getimagesize(SYSTEM_PHOTOS_DIRECTORY.'/'.$hash)) $error=5; } else { $error=8; } } elseif($file) { if (!eregi('(.jpg)|(.jpeg)$',$file)) $error=5; if (!file_exists($file)) $error=4; if (!$error) { if (!@copy($file, SYSTEM_PHOTOS_DIRECTORY.'/'.$hash)) $error=6; } $file_type='image/jpeg'; $file_name=substr($file,strrpos($file,'/')+1); if(!@getimagesize(SYSTEM_PHOTOS_DIRECTORY.'/'.$hash)) $error=5; } if ($error) { @unlink(SYSTEM_PHOTOS_DIRECTORY.'/'.$hash); } else { $resize_res=$resize_mode[$USER_PRIV[$id_cat]["resize_mode"]][1]; $resize_comp=$resize_mode[$USER_PRIV[$id_cat]["resize_mode"]][2]; if ($resize_res) Image_resize(SYSTEM_PHOTOS_DIRECTORY.'/'.$hash, $resize_res, $resize_res, $resize_comp, '', $rotate); Image_resize(SYSTEM_PHOTOS_DIRECTORY.'/'.$hash, MAX_RES_THUMBNAIL, MAX_RES_THUMBNAIL, COMPRESSION_THUMBNAIL, '_m'); Image_resize(SYSTEM_PHOTOS_DIRECTORY.'/'.$hash.'_m', 60, 60, COMPRESSION_THUMBNAIL, '2'); @chmod(SYSTEM_PHOTOS_DIRECTORY.'/'.$hash,0644); @chmod(SYSTEM_PHOTOS_DIRECTORY.'/'.$hash.'_m',0644); @chmod(SYSTEM_PHOTOS_DIRECTORY.'/'.$hash.'_m2',0644); $file_size=(filesize(SYSTEM_PHOTOS_DIRECTORY.'/'.$hash)); $query="INSERT INTO ".DB_PREFIX."photos2 (id, name, description, author, id_login, id_category, file_name, file_size, file_type, hash, date_add, date_publication, rating, rating_cnt, cnt)VALUES (NULL, '".$name."', '".$desc."', '".$author."', '".$login."', ".$id_cat.", '".$file_name."', '".$file_size."', '".$file_type."', '".$hash."', '".$date_add."', '".$date_public."', 0, 0, 0)"; db_query_exe($query); if ($USER_PRIV["ext"]["quota"]!=0) { $filessize=User_filessize($login); if(($filessize)>$USER_PRIV["ext"]["quota"]) { $query="SELECT id FROM ".DB_PREFIX."photos2 WHERE hash='".$hash."'"; $array=db_query_select($query); Del_photo($array[0]["id"]); $error=7; } } if(EMAIL_NEW_PHOTO=='Y' && $USER_PRIV["ext"]["admin_mode"]!=1 && !$error) { $email=SYSTEM_MAIN_TITLE."\n"; $email.="---------------------------------------------------------------------\n"; $email.=$LA[347].": ".$file_name."\n"; $email.=$LA[319].': '.USER_LOGIN."\n"; $email.=$LA[313].': '.$USER_PRIV[$id_cat]["name"]."\n"; $email.=$LA[712].': '; $email.=($USER_PRIV[$id_cat]["moderate"]=='Y')? $LA[105] : $LA[106]; $email.="\n"; $email.="---------------------------------------------------------------------\n"; $title=SYSTEM_MAIN_TITLE.' - '.$LA[347]; send_Email(ADMIN_EMAIL,$title,$email); } } return $error; } function Photo_edit ($id, $name, $desc, $author, $id_cat) { $query="UPDATE ".DB_PREFIX."photos2 SET name='".$name."', description='".$desc."', author= '".$author."', id_category=".$id_cat." WHERE id=".$id; db_query_select($query); } ?> Can someone advise me on how to configure the inc_image.php file to accept bigger image files of up to 5mb? Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/120306-help-with-webalbum/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.