public function new_image($param) { $check_res = $this->checkImg(); if ($check_res[ "code" ] >= 0) { $file = request()->file($param[ "name" ]); if (empty($file)) return $this->error(); $tmp_name = $file->getPathname();//获取上传缓存文件 $original_name = $file->getOriginalName();//文件原名 // $file_path = $this->upload_path."/".$this->site_id . "/images/".date("Ymd"). '/'; $file_path = $this->path; // 检测目录 $checkpath_result = $this->checkPath($file_path);//验证写入文件的权限 if ($checkpath_result[ "code" ] < 0) return $checkpath_result; $file_name = $file_path . $this->createNewFileName(); $extend_name = $file->getOriginalExtension(); $thumb_type = $param[ "thumb_type" ]; //原图保存 $new_file = $file_name . "." . $extend_name; $image = Image::make($tmp_name); $width = $image->width();//图片宽 $height = $image->height();//图片高 $image = $this->imageWater($image); move_uploaded_file($tmp_name,$_SERVER['DOCUMENT_ROOT'].'/'.$new_file); $put_result = event("Put", [ "file_path" => $new_file, "key" => $new_file ], true); if (!empty($put_result)) { $this->deleteFile($new_file); if ($put_result[ "code" ] >= 0) { $info = $put_result[ "data" ][ "path" ]; } else { return $put_result; } } //云上传没有成功 保存到本地 return $this->success(['pic_path'=>$info], "UPLOAD_SUCCESS"); } else { //返回错误信息 return $check_res; } }