aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoricewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-05-01 15:42:01 +0000
committericewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-05-01 15:42:01 +0000
commit9d3ebe824929d119c23b688763c03232da8c4130 (patch)
tree863e0b7b14c03519d19b66c315f801b28ce2cddb
parentdc9f5014c298fe28983d024ad2d9e5d04b7f1dfa (diff)
downloadelgg-9d3ebe824929d119c23b688763c03232da8c4130.tar.gz
elgg-9d3ebe824929d119c23b688763c03232da8c4130.tar.bz2
Marcus Povey <marcus@dushka.co.uk>
* Download support git-svn-id: https://code.elgg.org/elgg/trunk@607 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--mod/file/actions/download.php26
-rw-r--r--mod/file/languages/en.php1
2 files changed, 25 insertions, 2 deletions
diff --git a/mod/file/actions/download.php b/mod/file/actions/download.php
index 4ea08ae84..19ef86d90 100644
--- a/mod/file/actions/download.php
+++ b/mod/file/actions/download.php
@@ -8,9 +8,31 @@
* @link http://elgg.com/
*/
-
+ // Get the guid
$file_guid = get_input("file_guid");
+ // Get the file
+ $file = get_entity($file_guid);
- echo "$file_guid";
+ if ($file)
+ {
+ $mime = $file->getMimeType();
+ if (!$mime) $mime = "application/octet-stream";
+
+ $filename = $file->getFilename();
+
+ header("Content-type: $mime");
+ header("Content-Disposition: attachment; filename=\"$filename\"");
+
+ $file->open("read");
+
+ while (!$file->eof())
+ {
+ echo $file->read(10240, $file->tell());
+ }
+
+ $file->close();
+ }
+ else
+ system_message(elgg_echo("file:downloadfailed"));
?> \ No newline at end of file
diff --git a/mod/file/languages/en.php b/mod/file/languages/en.php
index 451680430..eeae1de02 100644
--- a/mod/file/languages/en.php
+++ b/mod/file/languages/en.php
@@ -37,6 +37,7 @@
*/
'file:uploadfailed' => "Sorry; we could not save your file.",
+ 'file:downloadfailed' => "Sorry; this file is not available at this time.",
);