| 123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- namespace app\admin\controller;
- class Upload extends \app\common\controller\Upload
- {
- /**
- * @api {post} /upload/image 上传图片
- * @apiGroup Upload
- * @apiVersion 1.0.0
- * @apiUse header
- * @apiUse lang
- *
- * @apiParam {File} file 图像文件的路径(本地路径)
- * - 文件大小限制:最大 20MB。
- * - 支持图像格式:`jpg`, `jpeg`, `png`,`webp`。
- */
- public function uploadFile()
- {
- $type = request()->input('type');
- //商品分类上传图片要求尺寸是750*750
- if ($type && $type == 'category') {
- $image = request()->file('file');
- if ($image && $image->isValid()) {
- $imageSize = getimagesize($image->getRealPath());
- $width = $imageSize[0];
- $height = $imageSize[1];
- if ($width != 750 || $height != 750) {
- return $this->error("上传文件的图片大小不合符标准,标准尺寸为750×750。");
- }
- }
- }
- return parent::uploadFile();
- }
- }
|