From 471ea4dc0a69ec73270162a67e2e14bf3a204be5 Mon Sep 17 00:00:00 2001 From: edward Date: Thu, 21 Jan 2016 14:49:08 +0800 Subject: [PATCH] DataObjects/Images.php --- DataObjects/Images.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/DataObjects/Images.php b/DataObjects/Images.php index 154067bd..b06c65ac 100644 --- a/DataObjects/Images.php +++ b/DataObjects/Images.php @@ -658,6 +658,26 @@ class Pman_Core_DataObjects_Images extends DB_DataObject return false; } + require_once 'File/MimeType.php'; + $y = new File_MimeType(); + + if (in_array($this->mimetype, array( + 'text/application', + 'application/octet-stream', + 'image/x-png', // WTF does this? + 'image/pjpeg', // WTF does this? + 'application/x-apple-msg-attachment', /// apple doing it's magic... + 'application/vnd.ms-excel', /// sometimes windows reports csv as excel??? + 'application/csv-tab-delimited-table', // windows again!!? + ))) { // weird tyeps.. + $inf = pathinfo($this->filename); + $this->mimetype = $y->fromExt($inf['extension']); + } + + $ext = $y->toExt(trim((string) $this->mimetype )); + + $this->filename = $this->filename .'.'. $ext; + if (!$this->createFromData($data)) { return false; } -- 2.39.2