diff --git a/module/file/config.php b/module/file/config.php index f7dc597d20..7b55622f10 100644 --- a/module/file/config.php +++ b/module/file/config.php @@ -7,6 +7,8 @@ $config->file->mimes['default'] = 'application/octet-stream'; $config->file->imageExtensions = array('jpeg', 'jpg', 'gif', 'png'); $config->file->image2Compress = array('.jpg', '.bmp', '.jpeg'); +$config->file->charset = array('UTF-8' => 'UTF-8', 'GBK' => 'GBK', 'BIG5' => 'BIG5'); + $config->file->ueditor["imageActionName"] = "uploadimage"; $config->file->ueditor["imageFieldName"] = "upfile"; $config->file->ueditor["imageMaxSize"] = 2048000; diff --git a/module/file/control.php b/module/file/control.php index 2e72eda9a3..d080ceb988 100644 --- a/module/file/control.php +++ b/module/file/control.php @@ -133,25 +133,34 @@ class file extends control $fileTypes = 'txt|jpg|jpeg|gif|png|bmp|xml|html'; if(stripos($fileTypes, $file->extension) !== false and $mouse == 'left') $mode = 'open'; - /* If the mode is open, locate directly. */ - if($mode == 'open') + if(file_exists($file->realPath)) { - if(file_exists($file->realPath))$this->locate($file->webPath); - $this->app->triggerError("The file you visit $fileID not found.", __FILE__, __LINE__, true); - } - else - { - /* Down the file. */ - if(file_exists($file->realPath)) + /* If the mode is open, locate directly. */ + if($mode == 'open') { + if(stripos('txt|jpg|jpeg|gif|png|bmp', $file->extension) !== false) + { + $this->view->file = $file; + $this->view->charset = $this->get->charset ? $this->get->charset : $this->config->charset; + $this->view->fileType = ($file->extension == 'txt') ? 'txt' : 'image'; + $this->display(); + } + else + { + $this->locate($file->webPath); + } + } + else + { + /* Down the file. */ $fileName = $file->title . '.' . $file->extension; $fileData = file_get_contents($file->realPath); $this->sendDownHeader($fileName, $file->extension, $fileData); } - else - { - $this->app->triggerError("The file you visit $fileID not found.", __FILE__, __LINE__, true); - } + } + else + { + $this->app->triggerError("The file you visit $fileID not found.", __FILE__, __LINE__, true); } } diff --git a/module/file/lang/en.php b/module/file/lang/en.php index af66704224..f9f20b7b60 100644 --- a/module/file/lang/en.php +++ b/module/file/lang/en.php @@ -25,6 +25,7 @@ $lang->file->setPublic = "Set Public Template"; $lang->file->exportFields = "Fileds to be Exported"; $lang->file->defaultTPL = "Default Template"; $lang->file->setExportTPL = "Settings"; +$lang->file->preview = "Preview"; $lang->file->errorNotExists = "'%s' is not found."; $lang->file->errorCanNotWrite = "'%s' is not writable. Please change its permission. Enter sudo chmod -R 777 '%s' in Linux."; diff --git a/module/file/lang/zh-cn.php b/module/file/lang/zh-cn.php index 15c7908b0f..63ec72e365 100644 --- a/module/file/lang/zh-cn.php +++ b/module/file/lang/zh-cn.php @@ -25,6 +25,7 @@ $lang->file->setPublic = "设置公共模板"; $lang->file->exportFields = "要导出字段"; $lang->file->defaultTPL = "默认模板"; $lang->file->setExportTPL = "设置"; +$lang->file->preview = "预览"; $lang->file->errorNotExists = "文件夹 '%s' 不存在"; $lang->file->errorCanNotWrite = "文件夹 '%s' 不可写,请改变文件夹的权限。在linux中输入指令:sudo chmod -R 777 '%s'"; diff --git a/module/file/view/download.html.php b/module/file/view/download.html.php new file mode 100644 index 0000000000..f8b9870ff2 --- /dev/null +++ b/module/file/view/download.html.php @@ -0,0 +1,56 @@ + +id);?> + +