public function add(Request $request) { $file = $request->file('filefield'); $extension = $file->getClientOriginalExtension(); Storage::disk('local')->put($file->getFilename() . '.' . $extension, File::get($file)); $entry = new Fileentry(); $entry->mime = $file->getClientMimeType(); $entry->original_filename = $file->getClientOriginalName(); $entry->filename = $file->getFilename() . '.' . $extension; $entry->save(); return redirect('fileentry'); }
public function get($filename) { $entry = Fileentry::where('filename', '=', $filename)->firstOrFail(); $file = Storage::disk('local')->get($entry->filename); return (new Response($file, 200))->header('Content-Type', $entry->mime); }