当前位置:网站首页>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'],
],
]);
}
边栏推荐
- Dark horse shopping mall ---2 Distributed file storage fastdfs
- Architects reveal the difference between working in Alibaba, Tencent and meituan
- ARM 立即数
- 属性分解 GAN 复现 实现可控人物图像合成
- 20、wpf之MVVM命令绑定
- 图片打标签之获取图片在ImageView中的坐标
- Arm immediate
- confluence7.4. X upgrade record
- New and old cluster migration of Minio data
- 设置图片的透明度从左到右渐变
猜你喜欢

The cloud native data lake has passed the evaluation and certification of the ICT Institute with its storage, computing, data management and other capabilities

Windows下MySQL的安装和删除

Why can't you Ping the website but you can access it?

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

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

【OceanBase】OceanBase简介及其与MySQL的比较

ROS notes (06) - definition and use of topic messages

How to use ARIMA model for prediction?

揭秘GaussDB(for Redis):全面對比Codis

Découvrir gaussdb (pour redis): une comparaison complète avec Codis
随机推荐
sudo: ulimit: command not found
New and old cluster migration of Minio data
Gradle knowledge points
Database Series: MySQL index optimization summary (comprehensive version)
Why should Apple change objc_ Type declaration for msgsend
R语言使用epiDisplay包的followup.plot函数可视化多个ID(病例)监测指标的纵向随访图、使用stress.type参数指定强调线的id子集的线条的类型(type)
SQL function summary
How to use SPSS to do grey correlation analysis? Quick grasp of hand-to-hand Teaching
R语言使用scale函数对神经网络的输入数据进行最小最大缩放、把数据缩放到0到1之间、并划分数据集为训练集和测试集
Use PHP script to view the opened extensions
Dark horse shopping mall ---8 Microservice gateway and JWT token
R语言dplyr包summarise_at函数计算dataframe数据中多个数据列(通过向量指定)的计数个数、均值和中位数、在每个函数内部指定na.rm参数、通过list指定函数列表
R language uses GLM function to build Poisson logarithmic linear regression model, processes three-dimensional contingency table data to build saturation model, and poisgof function of epidisplay pack
黑马畅购商城---1.项目介绍-环境搭建
apple 为什么要改 objc_msgSend 的类型申明
2022年首期Techo Day腾讯技术开放日将于6月28日线上举办
PD1.4转HDMI2.0转接线拆解。
学习笔记 2022 综述 | 自动图机器学习,阐述 AGML 方法、库与方向
2022 meisai e topic ideas sharing + translation
SDN system method | 9 Access network