From 4e0c1576475390faa2f1fb4c4dc2902a953f440e Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Wed, 25 Feb 2009 12:16:53 +0000 Subject: First commit --- actions/download.php | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 actions/download.php (limited to 'actions/download.php') diff --git a/actions/download.php b/actions/download.php new file mode 100644 index 000000000..31f21f0f5 --- /dev/null +++ b/actions/download.php @@ -0,0 +1,43 @@ +originalfilename; + $mime = $file->mimetype; + + header("Content-type: $mime"); + if (strpos($mime, "image/")!==false) + header("Content-Disposition: inline; filename=\"$filename\""); + else + header("Content-Disposition: attachment; filename=\"$filename\""); + + + $readfile = new ElggFile($file_guid); + $readfile->owner_guid = $file->owner_guid; + //$readfile->setFilename($filename); + + $contents = $readfile->grabFile(); + + if (empty($contents)) + echo file_get_contents(dirname(dirname(__FILE__)) . "/graphics/icons/general.jpg" ); + else + echo $contents; + + exit; + } + else + register_error(elgg_echo("image:downloadfailed")); + +?> \ No newline at end of file -- cgit v1.2.3