$image = \think\Image::open ( $path . '/' . $info->getSaveName () );
$image->thumb ( 100, 100,1 )->save ( $path . '/thumb/' . $info->getSaveName () );其中这个save的路径不会自动创建 修改了文件think-image\src\Image.php的115行 save 函数
/**
* 保存图像
* @param string $pathname 图像保存路径名称
* @param null|string $type 图像类型
* @param int $quality 图像质量
* @param bool $interlace 是否对JPEG类型图像设置隔行扫描
* @return $this
*/
public function save($pathname, $type = null, $quality = 80, $interlace = true)
{
$position = strrpos($pathname,'/');
$path = substr($pathname,0,$position);
if(!file_exists($path)){
mkdir($path,0777,true);
}
//自动获取图像类型
if (is_null($type)) {
$type = $this->info['type'];
} else {
$type = strtolower($type);
}
//保存图像
if ('jpeg' == $type || 'jpg' == $type) {
//JPEG图像设置隔行扫描
imageinterlace($this->im, $interlace);
imagejpeg($this->im, $pathname, $quality);
} elseif ('gif' == $type && !empty($this->gif)) {
$this->gif->save($pathname);
} elseif ('png' == $type) {
//设定保存完整的 alpha 通道信息
imagesavealpha($this->im, true);
//ImagePNG生成图像的质量范围从0到9的
imagepng($this->im, $pathname, min((int) ($quality / 10), 9));
} else {
$fun = 'image' . $type;
$fun($this->im, $pathname);
}
return $this;
}在函数开头添加了下面这段$position = strrpos($pathname,'/');
$path = substr($pathname,0,$position);
if(!file_exists($path)){
mkdir($path,0777,true);
}欢迎使用tp5的友友一同学习 QQ 群 564656678 最佳答案