diff options
author | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-05-01 15:42:01 +0000 |
---|---|---|
committer | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-05-01 15:42:01 +0000 |
commit | 9d3ebe824929d119c23b688763c03232da8c4130 (patch) | |
tree | 863e0b7b14c03519d19b66c315f801b28ce2cddb /mod/file/actions/download.php | |
parent | dc9f5014c298fe28983d024ad2d9e5d04b7f1dfa (diff) | |
download | elgg-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.php | 26 |
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 |