summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
Diffstat (limited to 'system')
-rw-r--r--system/helpers/download_helper.php38
1 files changed, 31 insertions, 7 deletions
diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php
index a6463dfd7..9619c61b1 100644
--- a/system/helpers/download_helper.php
+++ b/system/helpers/download_helper.php
@@ -56,7 +56,7 @@ if ( ! function_exists('force_download'))
*
* Generates headers that force a download to happen
*
- * @param string filename
+ * @param mixed filename (or an array of local file path => destination filename)
* @param mixed the data to be downloaded
* @param bool whether to try and send the actual file MIME type
* @return void
@@ -69,14 +69,38 @@ if ( ! function_exists('force_download'))
}
elseif ($data === NULL)
{
- if ( ! @is_file($filename) OR ($filesize = @filesize($filename)) === FALSE)
+ // Is $filename an array as ['local source path' => 'destination filename']?
+ if (is_array($filename))
{
- return;
+ if (count($filename) !== 1)
+ {
+ return;
+ }
+
+ $filepath = key($filename);
+ $filename = current($filename);
+
+ if (is_int($filepath))
+ {
+ return;
+ }
+
+ if ( ! @is_file($filepath) OR ($filesize = @filesize($filepath)) === FALSE)
+ {
+ return;
+ }
+ }
+ else
+ {
+ if ( ! @is_file($filename) OR ($filesize = @filesize($filename)) === FALSE)
+ {
+ return;
+ }
+
+ $filepath = $filename;
+ $filename = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $filename));
+ $filename = end($filename);
}
-
- $filepath = $filename;
- $filename = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $filename));
- $filename = end($filename);
}
else
{