Php 将图像复制到多个文件夹
我编写了一个经过测试的工作代码,用于减少图像大小,在上传图像时将图像从一个文件夹复制到另一个文件夹。它将图像大小减小到宽度300和高度300 我还想减少相同的图像大小,宽度为100,高度为100,这样我就可以使用最小的图像作为个人资料图片和电子邮件收件箱图像。而另一个则在用户相册上显示300的图像和300的高度 我想上传的图像复制到2个不同的大小的宽度300和高度300和100和高度100 请帮帮我Php 将图像复制到多个文件夹,php,Php,我编写了一个经过测试的工作代码,用于减少图像大小,在上传图像时将图像从一个文件夹复制到另一个文件夹。它将图像大小减小到宽度300和高度300 我还想减少相同的图像大小,宽度为100,高度为100,这样我就可以使用最小的图像作为个人资料图片和电子邮件收件箱图像。而另一个则在用户相册上显示300的图像和300的高度 我想上传的图像复制到2个不同的大小的宽度300和高度300和100和高度100 请帮帮我 if(move_uploaded_file($this->tem_
if(move_uploaded_file($this->tem_path, $terger_path)){
$exe = explode(".", $this->filename);
$ext = $exe[1];
$w = 300;
$h = 300;
$target = SITE_ROOT.DS.$this->img_path.DS.$this->filename;
$newcopy = SITE_ROOT.DS.$this->resize.DS.$this->filename;
list($w_orig, $h_orig) = getimagesize($target);
$scale_ratio = $w_orig / $h_orig;
if (($w / $h) > $scale_ratio) {
$w = $h * $scale_ratio;
} else {
$h = $w / $scale_ratio;
}
$img = "";
$ext = strtolower($ext);
if ($ext == "gif"){
$img = imagecreatefromgif($target);
} else if($ext =="png"){
$img = imagecreatefrompng($target);
} else {
$img = imagecreatefromjpeg($target);
}
$tci = imagecreatetruecolor($w, $h);
imagecopyresampled($tci, $img, 0, 0, 0, 0, $w, $h, $w_orig, $h_orig);
if(@imagejpeg($tci, $newcopy, 80)){
// return true;
$terger_path = SITE_ROOT.DS.$this->img_path.DS.$this->filename;
return unlink($terger_path) ? true : false;
}
}
这很简单: