2023-08-16 08:59:07 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Content;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use App\Http\Controllers\Forms\PublicFormController;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
|
|
|
|
class FileUploadController extends Controller
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Upload file to local temp
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Http\JsonResponse
|
|
|
|
*/
|
|
|
|
public function upload(Request $request)
|
|
|
|
{
|
2024-01-13 17:17:24 +00:00
|
|
|
$request->validate(['file' => 'required|file']);
|
2023-08-16 08:59:07 +00:00
|
|
|
$uuid = (string) Str::uuid();
|
|
|
|
$path = $request->file('file')->storeAs(PublicFormController::TMP_FILE_UPLOAD_PATH, $uuid);
|
|
|
|
|
|
|
|
return response()->json([
|
|
|
|
'uuid' => $uuid,
|
2024-02-23 10:54:12 +00:00
|
|
|
'key' => $path,
|
2023-08-16 08:59:07 +00:00
|
|
|
], 201);
|
|
|
|
}
|
|
|
|
}
|