Commit 07ce9696 authored by hujun's avatar hujun

全局图片上传

parent effe0dde
<?php
namespace app\index\controller;
use app\index\extend\Basic;
use app\api_broker\service\UploadFileService;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/7/3
* Time : 10:44
* Intro:
*/
class UploadImg extends Basic
{
private $uFService;
public function __construct($request = null)
{
parent::__construct($request);
$this->uFService = new UploadFileService();
}
/**
* 图片上传
* @return \think\Response
*/
public function uploadImg()
{
header('Access-Control-Allow-Origin:*');
set_time_limit(0);
$file = $_FILES['image'];
$type = request()->param('type');
$uploadResult = $this->uFService->upload($file, $type);
if ($uploadResult["code"] == 200) {
return $this->response("200", "图片上传成功", $uploadResult["msg"]);
} else {
return $this->response("101", $uploadResult["msg"]);
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment