/** *ajax生成产品缩略图 *@create 2015-1-5 *@author lck */ public function ajax_shop_thumb() { $image = new \Think\Image(); $image->open('.' . $_POST['path']); //将图片裁剪为400x400并保存为corp.jpg $min = img_rename($_POST['path'], "_min"); if (!file_exists('.' . $min)) { $image->thumb(50, 50)->save('.' . $min); } $mid = img_rename($_POST['path'], "_mid"); if (!file_exists('.' . $mid)) { $image->thumb(350, 350)->save('.' . $mid); } $this->ajaxReturn(array('status' => true)); }
/** * 清空图片组 */ public function clear() { $where['status'] = 0; $res = M('Picture')->where($where)->select(); foreach ($res as $key => $val) { if ($val['path']) { if (!unlink(substr($val['path'], 1))) { return false; } $min = img_rename($val['path'], "_min"); if (file_exists('.' . $min)) { if (!unlink('.' . $min)) { return false; } } $mid = img_rename($val['path'], "_mid"); if (file_exists('.' . $mid)) { if (!unlink('.' . $mid)) { return false; } } M('Picture')->where('id=' . $val['id'])->delete(); } } return true; }