Доброго времени суток, есть код: | Код | <?php require_once "lib/JsHttpRequest.php"; function resizeimаgе($filename, $newfile, $newwidth, $newheight) { $exp=strrchr($filename, "."); list($width, $height) = getimagesize($filename); if($width > $height && $newheight < $height){ $newheight = $height / ($width / $newwidth); } else if ($width < $height && $newwidth < $width) { $newwidth = $width / ($height / $newheight); } else { $newwidth = $width; $newheight = $height; }
$thumb = imagecreatetruecolor($newwidth, $newheight); if ($exp==".jpg" or $exp==".JPG" or $exp==".jpeg" or $exp==".JPEG") $source = imagecreatefromjpeg($filename); if ($exp==".png" or $exp==".PNG") $source = imagecreatefrompng($filename); if ($exp==".gif" or $exp==".GIF") $source = imagecreatefromgif($filename); imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); imagejpeg($thumb, $newfile); return true; imagedestroy($thumb); imagedestroy($source); } $JsHttpRequest =& new JsHttpRequest("windows-1251"); include("admin/config.php"); include ("lang/".$language."/language.php"); $xxx = $_REQUEST['xxx']; $upload_url = $_REQUEST['url']; $thumb_size = $_REQUEST['thumb_size']; $upl = $_FILES['upl']; if (!is_numeric($thumb_size)) die($lerror1." <br> <a href='index.php'>".$nazi."</a>"); if (!is_numeric($xxx) and $xxx!="") die($lerror2." <a href='index.php'> ".$nazi."</a>"); $ext = array("jpg", "jpeg", "JPG", "JPEG", "gif", "GIF", "png", "PNG"); $file_name=$upl['name']; if ($upload_url!="") $file_name=$upload_url; if (!in_array(end(explode(".", $file_name)), $ext)) die($lerror3." <a href='index.php'> <br> ".$nazi."</a>"); $file_name=md5(time().rand().time()); if ($upload_url!="") $file_ext=explode(".", $upload_url); else $file_ext=explode(".", $upl['name']); if ($xxx==1) $url = $file_name."_xxx.".end($file_ext); else $url = $file_name.".".end($file_ext); $http_url = explode("/", $_SERVER['REQUEST_URI']); foreach($http_url as $key => $val) { if (end($http_url)!=$val) $http .= $val."/"; } $file_to_upload = $upl['tmp_name']; if (isset($upload_url)){ $file_to_upload = $upload_url; }
include("admin/config.php"); if($js==1) { $jsc="rel='lightbox'"; } else { $jsc=""; }
$http_url = "http://".$_SERVER['HTTP_HOST'].$http."upload_image/".$url; $http_thumb_url = "http://".$_SERVER['HTTP_HOST'].$http."upload_image/thumb/".$url; if (copy ($file_to_upload, "upload_image/".$url)) { resizeimаgе("upload_image/".$url, "upload_image/thumb/".$url, $thumb_size, $thumb_size) or die("Error!"); $result = "<center><p>".$lyzezagry." <br> <a href='index.php'> ".$leve."</a></p>"; $result .= "<a ".$jsc." href='$http_url'><img src='$http_thumb_url' border=0></a><br><br>"; if ($xxx==1) $result = "<p>Изображение доступно только для лиц старше 13 лет <br> <a href='index.php'>Загрузить еще</a></p><a ".$jsc." href='$http_url'><img src='$http_thumb_url' border=0></a><br><br>"; $result .= "<font>".$ladressiii.":</font><br>"; $result .= "<input class='uploadlinks' type=\"text\" size=\"60\" onclick=\"this.select()\" value=\"$http_url\"><br><br>"; $result .= "<font>BBCode:</font><br>"; $result .= "<input class='uploadlinks' type=\"text\" size=\"60\" onclick=\"this.select()\" value=\"[img]".$http_url."[/img]\"><br><br>"; $result .= "<font>HTML:</font><br>"; $result .= "<input class='uploadlinks' type=\"text\" size=\"60\" onclick=\"this.select()\" value=\"<a href='$http_url' target=_blank><img src='$http_thumb_url' border=0></a>\"><br><br></center>"; echo $result; } else die($lerror2);
?>
|
Он нормально загружает изображения формата jpg, jpeg, gif, png. Пытаюсь "научить его" принимать еще и формат файла bmp, добавляю следующий код в двух местах, здесь: | Код | if ($exp==".bmp" or $exp==".BMP") $source = imagecreatefromwbmp($filename);
|
и здесь: | Код | $ext = array("jpg", "jpeg", "JPG", "JPEG", "gif", "GIF", "png", "PNG", "bmp", "BMP");
|
Но скрипт выдает Ошибку ($lerror2). Подскажите пожалуйста, что не так делаю ? Это сообщение отредактировал(а) Sice - 18.8.2009, 10:07
|