|
|
@ -12,7 +12,7 @@ use Illuminate\Http\Request; |
|
|
*/ |
|
|
*/ |
|
|
class UploadController extends Controller |
|
|
class UploadController extends Controller |
|
|
{ |
|
|
{ |
|
|
private $save_path = '/uploads/'; |
|
|
|
|
|
|
|
|
private string $save_path = '/user/'; |
|
|
|
|
|
|
|
|
//图片上传
|
|
|
//图片上传
|
|
|
public function image(Request $request) |
|
|
public function image(Request $request) |
|
|
@ -24,10 +24,10 @@ class UploadController extends Controller |
|
|
|
|
|
|
|
|
$mime = $image->getMimeType(); |
|
|
$mime = $image->getMimeType(); |
|
|
if (!in_array($mime, ['image/jpeg', 'image/png', 'image/gif', 'image/pjpeg'])) { |
|
|
if (!in_array($mime, ['image/jpeg', 'image/png', 'image/gif', 'image/pjpeg'])) { |
|
|
return $this->error('所上传图片格式错误'); |
|
|
|
|
|
|
|
|
return $this->error('上传图片格式错误'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$path = $request->image->store('images', 'uploads'); |
|
|
|
|
|
return $this->success(['path' => env('APP_URL') . $this->save_path . $path]); |
|
|
|
|
|
|
|
|
$path = $request->image->store($this->save_path . 'images/' . $this->agent_id, 'public'); |
|
|
|
|
|
return $this->success(['path' => config('filesystems.disks.public.url') . '/' . $path]); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |