蛋了个疼,调试一晚自习上终于找到原因了,但是不知道怎么解决.尝试过转换但还是不行.求解
$a = new images;
$LF = "D:\WebServer\PHPnow\htdocs\u\1.jpg";
$NF = "D:\WebServer\PHPnow\htdocs\u\2.jpg";
$a->Thumbnail($LF,$NF,300,300);class images
{
private $max_width;
private $max_height;


//scale
public function __construct()
{

}

public function ChangeSize($file,$new_file,$width,$height)
{
$res = $this->loadImgRes($file);
if($res == false)
{
return false;
}
$originwidth = imagesx($res);
$originheight = imagesy($res);

$new_res = imagecreate($width,$height);
if(imagecopyresampled($new_res,$res,0,0,0,0,$width,$height,$originwidth,$originheight))
{
if($this->saveImg($new_res,$new_file))
{
imagedestroy($res);
imagedestroy($new_res);
return true;
}
else
{
return false;
}
}
else
{
return false;
} }

public function Thumbnail($file,$new_file,$max_width,$max_height)
{
$res = $this->loadImgRes($file);
$x = imagesx($res);
$y = imagesy($res);
if($res == false)
{
return false;
}
if($x > $max_width || $y > $max_height)
{
$x_scale = (int)($x / $max_width);
$y_scale = (int)($y / $max_height);
$scale = $x_scale > $y_scale?$x_scale:$y_scale;
$this->ChangeSize($file,$new_file,(int)($x / $scale),(int)($y / $scale));
}
return true;
}
private function loadImgRes(&$file)
{
if(!file_exists($file))
{
return false;
}
                //将这个判断注销后就会发现路径中的数字成了乱码 switch(strtolower($this->getFileType($file)))
{
case "gif":
if(function_exists("imagecreatefromgif"))
{
return imagecreatefromgif($file);
}
else
{
return false;
}
case "png":
if(function_exists("imagecreatefrompng"))
{
return imagecreatefrompng($file);
}
else
{
return false;
}
case "jpeg":
if(function_exists("imagecreatefromjpeg"))
{
return imagecreatefromjpeg($file);
}
else
{
return false;
}
case "jpg":
if(function_exists("imagecreatefromjpeg"))
{
return imagecreatefromjpeg($file);
}
else
{
return false;
}
default:
return false;
}
}

private function saveImg(&$res,$newfile)
{
switch(strtolower($this->getFileType($newfile)))
{
case "gif":
@imagegif($res,$newfile);
return true;
case "png":
@imagepng($res,$newfile);
return true;
case "jpeg":
@imagejpeg($res,$newfile);
return true;
case "jpg":
@imagejpeg($res,$newfile);
return true;
default:
return false;
}
} private function getFileType($name)
{
$arr = explode('.',$name);
return $arr[count($arr) - 1];
}
}
使用mb_convert_encoding和iconv转换编码还是不行
测试环境:WIN2K3+APACHE+PHP5.2.14
PHP文件采用的UTF-8编码,WIN2K3应该是GBK编码
使用自己定义的编码转换函数codechange($str,"GBK","UTF-8")还是不行function codechange($str,$to_encoding,$in_encoding=NULL)
{
if(function_exists("mb_convert_encoding"))
{
if($in_encoding == NULL)
{
return mb_convert_encoding($str,$to_encoding);
}
else
{
return mb_convert_encoding($str,$to_encoding,$in_encoding);
}
}
else
{
if(function_exists("iconv") && $in_encoding != NULL)
{
return iconv($in_encoding,$to_encoding,$str);
}
else
{
return false;
}
}
}
真心求解啊