当前位置:网站首页>ThinkPHP upload image compression size
ThinkPHP upload image compression size
2022-06-25 12:26:00 【sr_ www】
function layuiUpload($path = '') {
$upload = new \Think\Upload();
$upload->maxSize = 2097152;
$upload->exts = ['jpg', 'jpeg', 'png', 'gif', 'doc', 'docx', 'xls', 'xlsx'];
$savePath = $path ? './upload/' . $path . '/' : './upload/';
$upload->rootPath = $savePath;
$upload->autoSub = false;
$res = $upload->upload();
if (\stristr($res['file']['type'], 'image')) {
// If the uploaded image is compressed
$image = new \Think\Image();
$image->open($savePath . $res['file']['savename']);
$image->thumb(800, 800)->save($savePath . $res['file']['savename']);
}
$this->ajaxReturn([
'code' => 0,
'msg' => '',
'data' => [
'fullSrc' => 'http://' . \currentDomain() . \str_replace('./', '/', $savePath) . $res['file']['savename'],
'src' => \str_replace('./', '/', $savePath) . $res['file']['savename'],
'fileName' => $res['file']['savename'],
],
]);
}
边栏推荐
- Is the online stock trading account opening ID card information safe?
- 15、wpf之button样式小记
- [论]Learning Dynamic and Hierarchical Traffic Spatiotemporal Features with Transformer
- 实现领域驱动设计 - 使用ABP框架 - 系列文章汇总
- Full nanny tutorial of Market Research Competition (experience sharing)
- R语言caTools包进行数据划分、scale函数进行数据缩放、e1071包的naiveBayes函数构建朴素贝叶斯模型
- What are redis avalanche, penetration and breakdown?
- R language uses the multinom function of NNET package to build an unordered multi classification logistic regression model, and uses the lrtest function of epidisplay package to perform multiple model
- 学习笔记 2022 综述 | 自动图机器学习,阐述 AGML 方法、库与方向
- Web project development process
猜你喜欢

confluence7.4.X升级实录

使用php脚本查看已开启的扩展

2022年首期Techo Day腾讯技术开放日将于6月28日线上举办

Dark horse shopping mall ---2 Distributed file storage fastdfs

为什么ping不通网站 但是却可以访问该网站?

Explanation of ideas and sharing of pre-processing procedures for 2021 US game D (with pre-processing data code)

Today, I will explain to you what is DFI and its development prospects

19. Implementation of MVVM architecture based on WPF event to command

Use PHP script to view the opened extensions

K8s, docker compose install MySQL 8.0.18
随机推荐
What is principal component analysis? Dimension reduction of classical case analysis variables
Repair the error that ECSHOP background orders prompt insufficient inventory when adding goods. Please reselect
Dark horse shopping mall ---3 Commodity management
The dist function of R language calculates the distance between two samples in dataframe data, returns the distance matrix between samples, and specifies the distance calculation method through the me
Kotlin study notes
ARM 立即数
Gradle knowledge points
黑马畅购商城---1.项目介绍-环境搭建
What are redis avalanche, penetration and breakdown?
一款好用的印章设计工具 --(可转为ofd文件)
[regression analysis] understand ridge regression with case teaching
Linear regression of common mathematical modeling models for College Students
Ten commandments of self-learning in machine learning
How do super rookies get started with data analysis?
Dynamic proxy
apple 为什么要改 objc_msgSend 的类型申明
Arm immediate
黑马畅购商城---8.微服务网关Gateway和Jwt令牌
Uncover gaussdb (for redis): comprehensive comparison of CODIS
plt.gca()画框及打标签