没有将上传路径的定义放到设置中,这是一个不常用的定义,放在config.inc.php里添加一行`define('__TYPECHO_UPLOAD_DIR__', 'xxxx');`即可
增加jpeg支持
This commit is contained in:
joyqi
2013-12-24 16:01:37 +08:00
parent c0930d3f31
commit 51dbbffc6d
3 changed files with 7 additions and 6 deletions
+1 -1
View File
@@ -319,7 +319,7 @@ class Widget_Options extends Typecho_Widget
if (NULL != $this->attachmentTypes) {
$attachmentTypes = str_replace(
array('@image@', '@media@', '@doc@'),
array('gif,jpg,png,tiff,bmp', 'mp3,wmv,wma,rmvb,rm,avi,flv',
array('gif,jpg,jpeg,png,tiff,bmp', 'mp3,wmv,wma,rmvb,rm,avi,flv',
'txt,doc,docx,xls,xlsx,ppt,pptx,zip,rar,pdf'), $this->attachmentTypes);
$attachmentTypesResult = array_unique(array_map('trim', explode(',', $attachmentTypes)));
+1 -1
View File
@@ -116,7 +116,7 @@ class Widget_Options_General extends Widget_Abstract_Options implements Widget_I
}
$attachmentTypesOptions = array(
'@image@' => _t('图片文件') . ' <code>(gif jpg png tiff bmp)</code>',
'@image@' => _t('图片文件') . ' <code>(gif jpg jpeg png tiff bmp)</code>',
'@media@' => _t('多媒体文件') . ' <code>(mp3 wmv wma rmvb rm avi flv)</code>',
'@doc@' => _t('常用档案文件') . ' <code>(txt doc docx xls xlsx ppt pptx zip rar pdf)</code>',
'@other@' => _t('其他格式 %s', ' <input type="text" class="w-50 text-s mono" name="attachmentTypesOther" value="' . htmlspecialchars($attachmentTypesOtherValue) . '" />'),
+5 -4
View File
@@ -19,7 +19,7 @@
class Widget_Upload extends Widget_Abstract_Contents implements Widget_Interface_Do
{
//上传文件目录
const UPLOAD_PATH = '/usr/uploads';
const UPLOAD_DIR = '/usr/uploads';
/**
* 创建上传路径
@@ -75,8 +75,8 @@ class Widget_Upload extends Widget_Abstract_Contents implements Widget_Interface
$options = Typecho_Widget::widget('Widget_Options');
$date = new Typecho_Date($options->gmtTime);
$path = Typecho_Common::url(self::UPLOAD_PATH, __TYPECHO_ROOT_DIR__)
. '/' . $date->year . '/' . $date->month;
$path = Typecho_Common::url(defined('__TYPECHO_UPLOAD_DIR__') ? __TYPECHO_UPLOAD_DIR__ : self::UPLOAD_DIR,
__TYPECHO_ROOT_DIR__) . '/' . $date->year . '/' . $date->month;
//创建上传目录
if (!is_dir($path)) {
@@ -112,7 +112,8 @@ class Widget_Upload extends Widget_Abstract_Contents implements Widget_Interface
//返回相对存储路径
return array(
'name' => $file['name'],
'path' => self::UPLOAD_PATH . '/' . $date->year . '/' . $date->month . '/' . $fileName,
'path' => (defined('__TYPECHO_UPLOAD_DIR__') ? __TYPECHO_UPLOAD_DIR__ : self::UPLOAD_DIR)
. '/' . $date->year . '/' . $date->month . '/' . $fileName,
'size' => $file['size'],
'type' => $ext,
'mime' => Typecho_Common::mimeContentType($path)