.gif грузятся на ура, а вот .jpg .jpeg никак не хотят... Посмотрите плиз в чем ошибка?
Функция, которую я использую для загрузки изображений:
function makepic($fileinfo,$wwwdir,$code){
global $image_path; //это водяной знак
$allowed = array ('gif','jpg','jpeg');
$filename = trim($fileinfo['name'], "\x00..\x1F");
$tmpname = explode('.',$filename);
$extension = strtolower($tmpname[count($tmpname)-1]);
$allowed = in_array($extension,$allowed) ? true : false ;
if ($allowed){
if (extension_loaded('gd')){
list($width, $height) = getimagesize($fileinfo['tmp_name']);
if ($width > "600") {$new_width="600"; $position_x="0"; $position_y="0";}
else{$new_width=$width; $wp="600";$position_x=($wp-$width)/2; if ($height>="450"){$position_y="0";}else{$hp="450";$position_y=($hp-$height)/2;}}
$d_width=$width/$new_width;
$new_height=$height/$d_width;
$gdinfo = gd_info();
$image = imagecreatetruecolor(600, 450);
$bg = imagecolorallocate ( $image, 255, 255, 255 );
imagefill ( $image, 0, 0, $bg );
if ($extension == 'gif' && $gdinfo['GIF Create Support'] ){
$nimage = imagecreatefromgif($fileinfo['tmp_name']);
imagecopyresampled($image, $nimage, $position_x, $position_y, 0, 0, $new_width, $new_height, $width, $height);
$watermark = imagecreatefrompng($image_path);
imagecopyresampled($image, $watermark, 0, 0, 0, 0, 600, 450, 600, 450);
imagedestroy($nimage); imagedestroy($watermark);
$nfile=$code."-".$fileinfo['name'];
if (!imagegif($image, $wwwdir.$nfile, 90)){return false;}}
if ($extension == 'jpg' and $gdinfo['JPG Support'] ){
$nimage = imagecreatefromjpeg($fileinfo['tmp_name']);
imagecopyresampled($image, $nimage, $position_x, $position_y, 0, 0, $new_width, $new_height, $width, $height);
$watermark = imagecreatefrompng($image_path);
imagecopyresampled($image, $watermark, 0, 0, 0, 0, 600, 450, 600, 450);
imagedestroy($nimage); imagedestroy($watermark);
$nfile=$code."-".$fileinfo['name'];
if (!imagejpeg($image, $wwwdir.$nfile, 90)){return false;}}
return true;}
else{return true;}}else{return false;}}