商品的缩略图

商品的缩略图

复制一份之前品牌模块的model模型文件,更名为

GoodsModel.class.php

maxSize = 3145728 ;// 设置附件上传大小 $upload->exts = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型 // $upload->autoSub = false; $upload->savePath = './Public/Uploads/Goods/'; // 设置附件上传目录 $upload->rootPath = './'; $info = $upload->uploadOne($_FILES['original']); $original=$info['savepath'].$info['savename']; $max_thumb=$info['savepath'].'max_'.$info['savename']; $mid_thumb=$info['savepath'].'mid_'.$info['savename']; $sm_thumb=$info['savepath'].'sm_'.$info['savename']; $image = new \Think\Image(); $image->open($original); $image->thumb(362, 362)->save($max_thumb); $image->thumb(222, 222)->save($mid_thumb); $image->thumb(67, 67)->save($sm_thumb); $data['original']=$original; $data['max_thumb']=$max_thumb; $data['mid_thumb']=$mid_thumb; $data['sm_thumb']=$sm_thumb; } } }

控制器 GoodsController.class.php

public function add(){ $goods=D('goods'); if(IS_POST){ if($goods->create()){ if ($goods->add()) { $this->success('添加品牌成功',U('index')); }else{ $this->error('添加品牌失败'); } }else{ $this->error($goods->getError()); } return; } $cateres=D('cate')->catetree(); $this->assign('cateres',$cateres); $brandres=D('brand')->select(); $this->assign('brandres',$brandres); $this->display(); }

QQ截图20170629160518.png

QQ截图20170629160541.png

Meneruskan pembelajaran
||
maxSize = 3145728 ;// 设置附件上传大小 $upload->exts = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型 // $upload->autoSub = false; $upload->savePath = './Public/Uploads/Goods/'; // 设置附件上传目录 $upload->rootPath = './'; $info = $upload->uploadOne($_FILES['original']); $original=$info['savepath'].$info['savename']; $max_thumb=$info['savepath'].'max_'.$info['savename']; $mid_thumb=$info['savepath'].'mid_'.$info['savename']; $sm_thumb=$info['savepath'].'sm_'.$info['savename']; $image = new \Think\Image(); $image->open($original); $image->thumb(362, 362)->save($max_thumb); $image->thumb(222, 222)->save($mid_thumb); $image->thumb(67, 67)->save($sm_thumb); $data['original']=$original; $data['max_thumb']=$max_thumb; $data['mid_thumb']=$mid_thumb; $data['sm_thumb']=$sm_thumb; } } }
serahkan Tetapkan Semula Kod
Tentang kita Penafian Sitemap
Laman web PHP Cina:Latihan PHP dalam talian kebajikan awam,Bantu pelajar PHP berkembang dengan cepat!