aboutsummaryrefslogtreecommitdiff
path: root/mod/file/actions
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2012-06-16 22:05:07 -0400
committerCash Costello <cash.costello@gmail.com>2012-06-16 22:05:07 -0400
commit3f42ca11e752696d9aaafe9b006d8e0f07136928 (patch)
tree01cf3b9b767020bb1b894c1ada684e19cab5c3a7 /mod/file/actions
parentab2072983b4f35c0495f920409f0f5bf5c75ee27 (diff)
downloadelgg-3f42ca11e752696d9aaafe9b006d8e0f07136928.tar.gz
elgg-3f42ca11e752696d9aaafe9b006d8e0f07136928.tar.bz2
Fixes #4079 detecting docx, xlsx, and pptx files in file plugin
Diffstat (limited to 'mod/file/actions')
-rw-r--r--mod/file/actions/file/upload.php25
1 files changed, 24 insertions, 1 deletions
diff --git a/mod/file/actions/file/upload.php b/mod/file/actions/file/upload.php
index 5242cbda2..d72d04eb7 100644
--- a/mod/file/actions/file/upload.php
+++ b/mod/file/actions/file/upload.php
@@ -94,8 +94,31 @@ if (isset($_FILES['upload']['name']) && !empty($_FILES['upload']['name'])) {
$filestorename = elgg_strtolower(time().$_FILES['upload']['name']);
}
- $mime_type = $file->detectMimeType($_FILES['upload']['tmp_name'], $_FILES['upload']['type']);
$file->setFilename($prefix . $filestorename);
+ $mime_type = ElggFile::detectMimeType($_FILES['upload']['tmp_name'], $_FILES['upload']['type']);
+
+ // hack for Microsoft zipped formats
+ $info = pathinfo($_FILES['upload']['name']);
+ $office_formats = array('docx', 'xlsx', 'pptx');
+ if ($mime_type == "application/zip" && in_array($info['extension'], $office_formats)) {
+ switch ($info['extension']) {
+ case 'docx':
+ $mime_type = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
+ break;
+ case 'xlsx':
+ $mime_type = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
+ break;
+ case 'pptx':
+ $mime_type = "application/vnd.openxmlformats-officedocument.presentationml.presentation";
+ break;
+ }
+ }
+
+ // check for bad ppt detection
+ if ($mime_type == "application/vnd.ms-office" && $info['extension'] == "ppt") {
+ $mime_type = "application/vnd.ms-powerpoint";
+ }
+
$file->setMimeType($mime_type);
$file->originalfilename = $_FILES['upload']['name'];
$file->simpletype = file_get_simple_type($mime_type);