From f044b429e37f1aa7676797b4c22a1bc8f300095f Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 16 Jun 2011 20:40:30 -0500 Subject: [PATCH] improved comments to download class. --- system/download.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/system/download.php b/system/download.php index 37778019..33800860 100644 --- a/system/download.php +++ b/system/download.php @@ -101,7 +101,8 @@ class Download { ); /** - * Create a download response. + * Create a download response. The proper headers will be sent + * to the browser to force the file to be downloaded. * * @param string $path * @param string $name @@ -109,22 +110,23 @@ class Download { */ public static function file($path, $name = null) { - // ----------------------------------------------------- - // If no filename was given, use the path basename. - // ----------------------------------------------------- if (is_null($name)) { $name = basename($path); } - return Response::make(file_get_contents($path))->header('Content-Description', 'File Transfer') - ->header('Content-Type', static::mime(pathinfo($path, PATHINFO_EXTENSION))) - ->header('Content-Disposition', 'attachment; filename="'.$name.'"') - ->header('Content-Transfer-Encoding', 'binary') - ->header('Expires', 0) - ->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0') - ->header('Pragma', 'public') - ->header('Content-Length', filesize($path)); + $response = Response::make(file_get_contents($path)); + + $response->header('Content-Description', 'File Transfer'); + $response->header('Content-Type', static::mime(pathinfo($path, PATHINFO_EXTENSION))); + $response->header('Content-Disposition', 'attachment; filename="'.$name.'"'); + $response->header('Content-Transfer-Encoding', 'binary'); + $response->header('Expires', 0); + $response->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0'); + $response->header('Pragma', 'public'); + $response->header('Content-Length', filesize($path)); + + return $response; } /**