aboutsummaryrefslogtreecommitdiff
path: root/mod/file/actions/download.php
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 /mod/file/actions/download.php
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
Diffstat (limited to 'mod/file/actions/download.php')
-rw-r--r--mod/file/actions/download.php26
1 files changed, 24 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