diff options
| -rw-r--r-- | app/Http/Controllers/SiteController.php | 1 | ||||
| -rw-r--r-- | resources/views/f.blade.php | 2 | ||||
| -rwxr-xr-x | routes/web.php | 10 |
3 files changed, 10 insertions, 3 deletions
diff --git a/app/Http/Controllers/SiteController.php b/app/Http/Controllers/SiteController.php index 251859f..a194468 100644 --- a/app/Http/Controllers/SiteController.php +++ b/app/Http/Controllers/SiteController.php @@ -72,6 +72,5 @@ class SiteController extends Controller $shellcmd = escapeshellcmd("python ./search4chan.py ${query} ${board}"); exec($shellcmd, $res, $ret); return $res; - } } diff --git a/resources/views/f.blade.php b/resources/views/f.blade.php index 708cf7e..cff2a4f 100644 --- a/resources/views/f.blade.php +++ b/resources/views/f.blade.php @@ -67,7 +67,7 @@ @if (is_dir($currentDir . '/' . $item)) <strong>Directory:</strong> <a href="?dir={{ $item }}">{{ htmlspecialchars($item) }}</a> @else - <a href="/f?file={{ $currentDir }}/{{ $item }}">{{ htmlspecialchars($item) }}</a> + <a href="/f/{{ $item }}">{{ htmlspecialchars($item) }}</a> @endif </li> @endif 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']); |
