21 lines
516 B
PHP
21 lines
516 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Http\Controllers;
|
||
|
|
||
|
use Illuminate\Http\Request;
|
||
|
use Illuminate\Support\Facades\Storage;
|
||
|
|
||
|
class FileController extends Controller
|
||
|
{
|
||
|
public function upload(Request $request)
|
||
|
{
|
||
|
$file = $request->file('upload');
|
||
|
$filename = uniqid() . '_' . $file->getClientOriginalName();
|
||
|
Storage::disk('public')->put($filename, file_get_contents($file));
|
||
|
$url = asset('storage/' . $filename);
|
||
|
return response()->json([
|
||
|
'url' => $url,
|
||
|
]);
|
||
|
}
|
||
|
}
|