Brand thumbnail modification

Model Layer Design
public function _before_update(&$data,$option){
if($_FILES['brand_logo']['tmp_name']){
if($data['oldlogo']){
if(file_exists($data['oldlogo'])){
@unlink($data['oldlogo']);
}
}
$upload = new \Think\Upload();// 实例化上传类
$upload->maxSize = 3145728 ;// 设置附件上传大小
$upload->exts = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
$upload->autoSub = false;
$upload->savePath = './Public/Uploads/Brand/'; // 设置附件上传目录
$upload->rootPath = './';
$info = $upload->uploadOne($_FILES['brand_logo']);
$logo=$info['savepath'].$info['savename'];
$image = new \Think\Image();
$image->open($logo);
$image->thumb(100, 30)->save($logo);
$data['brand_logo']=$logo;
}
}Accept the pictures sent from the hidden domain. If the picture is not an old picture, then delete the previous picture and then upload it again.
new file
public function _before_update(&$data,$option){
if($_FILES['brand_logo']['tmp_name']){
if($data['oldlogo']){
if(file_exists($data['oldlogo'])){
@unlink($data['oldlogo']);
}
}
$upload = new \Think\Upload();// 实例化上传类
$upload->maxSize = 3145728 ;// 设置附件上传大小
$upload->exts = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
$upload->autoSub = false;
$upload->savePath = './Public/Uploads/Brand/'; // 设置附件上传目录
$upload->rootPath = './';
$info = $upload->uploadOne($_FILES['brand_logo']);
$logo=$info['savepath'].$info['savename'];
$image = new \Think\Image();
$image->open($logo);
$image->thumb(100, 30)->save($logo);
$data['brand_logo']=$logo;
}
}
Preview
Clear
Students who have watched this course are also learning
Let's briefly talk about starting a business in PHP
Quick introduction to web front-end development
Large-scale practical Tianlongbabu development of Mini version MVC framework imitating the encyclopedia website of embarrassing things
Getting Started with PHP Practical Development: PHP Quick Creation [Small Business Forum]
Login verification and classic message board
Computer network knowledge collection
Quick Start Node.JS Full Version
The front-end course that understands you best: HTML5/CSS3/ES6/NPM/Vue/...[Original]
Write your own PHP MVC framework (40 chapters in depth/big details/must read for newbies to advance)
















The courseware is not available for download at the moment. The staff is currently organizing it. Please pay more attention to this course in the future~ 