图片上传

`

request->file('file'); $info = $file->validate(['size' => 5 * 1024 * 1024, 'ext' => 'gif,jpg,jpeg,bmp,png'])->move('upload'); if( $info ) { return $this->result( "/" . $info->getPathname(), 1, "上传成功", "json" ); } return $this->result('', 0, "上传失败", "json"); } /** * 上传文件到七牛云 */ public function upload(){ try{ $image = Upload::Image(); }catch (Exception $e){ return $this->result('', 0, "上传失败", "json"); } if($image){ return $this->result(config('qiniu.image_url')."/".$image, 1, "ok", "json"); } return $this->result('', 0, "上传失败", "json"); } } `
原文地址:https://www.cnblogs.com/aln0825/p/13196978.html