<?php

namespace App\Http\Controllers;

use App\Facades\UploadService;
use App\Http\Response\ResponseJson;
use App\Jobs\AddErrorLog;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;

class UploadController extends Controller
{
    use ResponseJson;
    public function uploadImage(Request $request)
    {
        if (!$request->hasFile('fileData')) {
            return $this->failure("请选择图片");
        }
        $file = $request->file();
        if (empty($file)) return $this->failure("请先选择图片");
        $url = UploadService::upload($file['fileData']);
        if (empty($url)) return $this->failure();
        return $this->success('ok', $url);
    }
}
