You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
655 B
26 lines
655 B
|
5 days ago
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Controllers\Api;
|
||
|
|
|
||
|
|
use App\Http\Controllers\Controller;
|
||
|
|
use Illuminate\Http\JsonResponse;
|
||
|
|
use Illuminate\Http\Request;
|
||
|
|
|
||
|
|
class UploadController extends Controller
|
||
|
|
{
|
||
|
|
public function store(Request $request): JsonResponse
|
||
|
|
{
|
||
|
|
$data = $request->validate([
|
||
|
|
'file' => ['required', 'file', 'max:20480'],
|
||
|
|
]);
|
||
|
|
|
||
|
|
$path = $data['file']->store('uploads', 'public');
|
||
|
|
return response()->json([
|
||
|
|
'path' => $path,
|
||
|
|
'url' => url('/storage/' . $path),
|
||
|
|
'mime' => $data['file']->getClientMimeType(),
|
||
|
|
'size' => $data['file']->getSize(),
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
}
|