<?php namespace App\Http\Controllers\Api; use Illuminate\Http\Request; use Illuminate\Support\Facades\Storage; /** * @title CommonController * @description CommonController * @package App\Http\Controllers\Api * @author zcstatham */ class CommonController extends BaseController { protected $rules = [ 'upload' => [ 'rules' => [ 'file' => 'required', 'file_type' => 'required' ] ] ]; public function upload(Request $request) { $file = $request->file('file'); $fileType = $request->input('file_type','files'); $disk = Storage::disk('oss'); $filename = $disk->putFile($fileType."/".date('Ymd'), $file); $url = str_replace('http://bmoc-files.oss-cn-hangzhou.aliyuncs.com', 'http://images.banmacar.com', $disk->getUrl($filename)); return $this->success(['url' => $url]); } }