diff options
| author | grothedev <grothedev@gmail.com> | 2024-12-09 22:55:19 -0600 |
|---|---|---|
| committer | grothedev <grothedev@gmail.com> | 2024-12-09 22:55:19 -0600 |
| commit | f86c77c22d2cbed970d75ef44e1038f7d9aaaa33 (patch) | |
| tree | e56f1f58c44bedcda9dc708a4f0a1307dd704ac1 /routes | |
| parent | 6678df9b26a0e0997c87a00439945dc4855b5041 (diff) | |
serve static files
Diffstat (limited to 'routes')
| -rwxr-xr-x | routes/web.php | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/routes/web.php b/routes/web.php index 02fe4a7..048bc20 100755 --- a/routes/web.php +++ b/routes/web.php @@ -13,7 +13,15 @@ Route::get('/dq', [SiteController::class, 'duneQuote']); Route::post('/f', [SiteController::class, 'uploadFiles']); //TODO later use file resource or FPR service Route::get('/f/{path}', function($path){ - return response()->file(storage_path('/public/uploads/' . $path)); + $storpath = storage_path('app/public/uploads/' . $path); + if (!file_exists($storpath)){ + return response()->json(['error' => 'file not found ' . $storpath]); + } + $mime = Storage::mimeType($storpath); + return response()->file($storpath, [ + 'Content-Type' => $mime, + 'Content-Disposition' => 'inline; filename="'.$path.'"' + ]); }); Route::get('/4', [SiteController::class, 'search4chan']); |
