public function download() { $key = \Request::input('key'); $password = \Request::input('password'); try { $file = File::whereRaw('file_key = ?', array($key))->firstOrFail(); if (password_verify($password, $file->password)) { $path = join(DIRECTORY_SEPARATOR, array(storage_path(), 'files', $file->file_name)); $stream = fopen($path, 'rb'); return response()->stream(function () use($stream) { while (!feof($stream)) { print fread($stream, 8192); flush(); } fclose($stream); }, 200, array('Content-Disposition' => 'attachment; filename=' . $file->file_name))->send(); } else { return redirect('download'); } } catch (\Exception $e) { return redirect('download'); } }