@@ -105,19 +105,19 @@ private function save($file) {
105
105
if (false !== $ image ) {
106
106
//是图像文件生成缩略图
107
107
$ thumbWidth = explode (', ' ,$ this ->thumbMaxWidth );
108
- $ thumbHeight = explode (', ' ,$ this ->thumbMaxHeight );
109
- $ thumbPrefix = explode (', ' ,$ this ->thumbPrefix );
110
- $ thumbSuffix = explode (', ' ,$ this ->thumbSuffix );
111
- $ thumbFile = explode (', ' ,$ this ->thumbFile );
112
- $ thumbPath = $ this ->thumbPath ?$ this ->thumbPath :dirname ($ filename ).'/ ' ;
108
+ $ thumbHeight = explode (', ' ,$ this ->thumbMaxHeight );
109
+ $ thumbPrefix = explode (', ' ,$ this ->thumbPrefix );
110
+ $ thumbSuffix = explode (', ' ,$ this ->thumbSuffix );
111
+ $ thumbFile = explode (', ' ,$ this ->thumbFile );
112
+ $ thumbPath = $ this ->thumbPath ?$ this ->thumbPath :dirname ($ filename ).'/ ' ;
113
113
// 生成图像缩略图
114
114
import ($ this ->imageClassPath );
115
115
for ($ i =0 ,$ len =count ($ thumbWidth ); $ i <$ len ; $ i ++) {
116
116
if (!empty ($ thumbFile [$ i ])) {
117
117
$ thumbname = $ thumbFile [$ i ];
118
118
}else {
119
- $ prefix = isset ($ thumbPrefix [$ i ])?$ thumbPrefix [$ i ]:$ thumbPrefix [0 ];
120
- $ suffix = isset ($ thumbSuffix [$ i ])?$ thumbSuffix [$ i ]:$ thumbSuffix [0 ];
119
+ $ prefix = isset ($ thumbPrefix [$ i ])?$ thumbPrefix [$ i ]:$ thumbPrefix [0 ];
120
+ $ suffix = isset ($ thumbSuffix [$ i ])?$ thumbSuffix [$ i ]:$ thumbSuffix [0 ];
121
121
$ thumbname = $ prefix .basename ($ filename ,'. ' .$ file ['extension ' ]).$ suffix ;
122
122
}
123
123
Image::thumb ($ filename ,$ thumbPath .$ thumbname .'. ' .$ file ['extension ' ],'' ,$ thumbWidth [$ i ],$ thumbHeight [$ i ],true );
@@ -163,7 +163,7 @@ public function upload($savePath ='') {
163
163
return false ;
164
164
}
165
165
}
166
- $ fileInfo = array ();
166
+ $ fileInfo = array ();
167
167
$ isUpload = false ;
168
168
169
169
// 获取上传的文件信息
@@ -173,10 +173,10 @@ public function upload($savePath ='') {
173
173
//过滤无效的上传
174
174
if (!empty ($ file ['name ' ])) {
175
175
//登记上传文件的扩展信息
176
- $ file ['key ' ] = $ key ;
177
- $ file ['extension ' ] = $ this ->getExt ($ file ['name ' ]);
178
- $ file ['savepath ' ] = $ savePath ;
179
- $ file ['savename ' ] = $ this ->getSaveName ($ file );
176
+ if (! isset ( $ file ['key ' ])) $ file [ ' key ' ] = $ key ;
177
+ $ file ['extension ' ] = $ this ->getExt ($ file ['name ' ]);
178
+ $ file ['savepath ' ] = $ savePath ;
179
+ $ file ['savename ' ] = $ this ->getSaveName ($ file );
180
180
181
181
// 自动检查附件
182
182
if ($ this ->autoCheck ) {
@@ -277,22 +277,23 @@ public function uploadOne($file,$savePath=''){
277
277
* @return array
278
278
*/
279
279
private function dealFiles ($ files ) {
280
- $ fileArray = array ();
281
- $ n = 0 ;
282
- foreach ($ files as $ file ){
283
- if (is_array ($ file ['name ' ])) {
284
- $ keys = array_keys ($ file );
285
- $ count = count ($ file ['name ' ]);
286
- for ($ i =0 ; $ i <$ count ; $ i ++) {
287
- foreach ($ keys as $ key )
288
- $ fileArray [$ n ][$ key ] = $ file [$ key ][$ i ];
289
- $ n ++;
290
- }
291
- }else {
292
- $ fileArray [$ n ] = $ file ;
293
- $ n ++;
294
- }
295
- }
280
+ $ fileArray = array ();
281
+ $ n = 0 ;
282
+ foreach ($ files as $ key =>$ file ){
283
+ if (is_array ($ file ['name ' ])) {
284
+ $ keys = array_keys ($ file );
285
+ $ count = count ($ file ['name ' ]);
286
+ for ($ i =0 ; $ i <$ count ; $ i ++) {
287
+ $ fileArray [$ n ]['key ' ] = $ key ;
288
+ foreach ($ keys as $ _key ){
289
+ $ fileArray [$ n ][$ _key ] = $ file [$ _key ][$ i ];
290
+ }
291
+ $ n ++;
292
+ }
293
+ }else {
294
+ $ fileArray [$ key ] = $ file ;
295
+ }
296
+ }
296
297
return $ fileArray ;
297
298
}
298
299
@@ -364,12 +365,12 @@ private function getSaveName($filename) {
364
365
private function getSubName ($ file ) {
365
366
switch ($ this ->subType ) {
366
367
case 'date ' :
367
- $ dir = date ($ this ->dateFormat ,time ()).'/ ' ;
368
+ $ dir = date ($ this ->dateFormat ,time ()).'/ ' ;
368
369
break ;
369
370
case 'hash ' :
370
371
default :
371
- $ name = md5 ($ file ['savename ' ]);
372
- $ dir = '' ;
372
+ $ name = md5 ($ file ['savename ' ]);
373
+ $ dir = '' ;
373
374
for ($ i =0 ;$ i <$ this ->hashLevel ;$ i ++) {
374
375
$ dir .= $ name {$ i }.'/ ' ;
375
376
}
@@ -422,8 +423,8 @@ private function check($file) {
422
423
423
424
// 自动转换字符集 支持数组转换
424
425
private function autoCharset ($ fContents , $ from ='gbk ' , $ to ='utf-8 ' ) {
425
- $ from = strtoupper ($ from ) == 'UTF8 ' ? 'utf-8 ' : $ from ;
426
- $ to = strtoupper ($ to ) == 'UTF8 ' ? 'utf-8 ' : $ to ;
426
+ $ from = strtoupper ($ from ) == 'UTF8 ' ? 'utf-8 ' : $ from ;
427
+ $ to = strtoupper ($ to ) == 'UTF8 ' ? 'utf-8 ' : $ to ;
427
428
if (strtoupper ($ from ) === strtoupper ($ to ) || empty ($ fContents ) || (is_scalar ($ fContents ) && !is_string ($ fContents ))) {
428
429
//如果编码相同或者非字符串标量则不转换
429
430
return $ fContents ;
0 commit comments