From ba099a0fe748e2ff664a4d2fd6fc6a0f5e00a9f7 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Thu, 21 Feb 2013 10:17:44 +0100 Subject: CLI: update_file_metadata: also update mimetypes Signed-off-by: Florian Pritz --- application/models/mfile.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'application/models') diff --git a/application/models/mfile.php b/application/models/mfile.php index ef48a87c5..203e2e101 100644 --- a/application/models/mfile.php +++ b/application/models/mfile.php @@ -79,13 +79,20 @@ class Mfile extends CI_Model { return $this->folder($hash).'/'.$hash; } + // Return mimetype of file + function mimetype($file) { + $fileinfo = new finfo(FILEINFO_MIME_TYPE); + $mimetype = $fileinfo->file($file); + + return $mimetype; + } + // Add a hash to the DB function add_file($hash, $id, $filename) { $userid = $this->muser->get_userid(); - $fileinfo = new finfo(FILEINFO_MIME_TYPE); - $mimetype = $fileinfo->file($this->file($hash)); + $mimetype = $this->mimetype($this->file($hash)); $filesize = filesize($this->file($hash)); $query = $this->db->query(' -- cgit v1.2.3-24-g4f1b