Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2013-12-10 15:05:39 +0400
committerVincent Petry <pvince81@owncloud.com>2013-12-10 15:42:26 +0400
commit409b5108896edda9adf916cd566dbce2d2b00351 (patch)
treeaaa25fd8a1ae7365a6df19df60b4f27f4086df4c /lib/private/response.php
parentbc3650e48c7ec4f05794c2bd98a90cca3090f1e3 (diff)
Moved content disposition code+workarounds to OCP\Response
Added new OC\Response API called setContentDispositionHeader() that contains the needed workarounds for UTF8 and IE. Refactored download code to use the new API. Removed unused trashbin download file.
Diffstat (limited to 'lib/private/response.php')
-rw-r--r--lib/private/response.php14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/private/response.php b/lib/private/response.php
index 674176d078b..1b9cb473d67 100644
--- a/lib/private/response.php
+++ b/lib/private/response.php
@@ -148,6 +148,20 @@ class OC_Response {
}
/**
+ * Sets the content disposition header (with possible workarounds)
+ * @param string $filename file name
+ * @param string $type disposition type, either 'attachment' or 'inline'
+ */
+ static public function setContentDispositionHeader( $filename, $type = 'attachment' ) {
+ if ( preg_match( "/MSIE/", $_SERVER["HTTP_USER_AGENT"] ) ) {
+ header( 'Content-Disposition: ' . rawurlencode($type) . '; filename="' . rawurlencode( $filename ) . '"' );
+ } else {
+ header( 'Content-Disposition: ' . rawurlencode($type) . '; filename*=UTF-8\'\'' . rawurlencode( $filename )
+ . '; filename="' . rawurlencode( $filename ) . '"' );
+ }
+ }
+
+ /**
* @brief Send file as response, checking and setting caching headers
* @param $filepath of file to send
*/