TanchoToplineCargo/app/Http/Controllers/FileController.php
2024-05-05 10:32:49 +05:45

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,
]);
}
}