管理员
![Rank: 64](template/yeei_dream1/css/yeei//star_level3.gif) ![Rank: 64](template/yeei_dream1/css/yeei//star_level3.gif) ![Rank: 64](template/yeei_dream1/css/yeei//star_level3.gif) ![Rank: 64](template/yeei_dream1/css/yeei//star_level3.gif)
论坛积分
分
威望 点
贡献值 个
金币 枚
|
- function imgs_uploads($path_old = null){
1 |/ U: _( L, i# j - 9 ?; \6 K9 g* {4 `5 H- E
- $images_path = './Uploads/image/shop/';
5 s: F" p. h# `$ _. Q8 Y' M - if (!is_dir($images_path)) {' b9 |* v: {" N) @( r3 w+ C
- mkdir($images_path);( h& D, c4 ]* W1 v/ \! K) R7 y
- } - W2 X% V; G8 Y6 {, O! c! L' g5 U
- . X) b# h+ w+ s; p; v
5 C! D+ v6 B% S" P$ D5 r- $upload = new \Think\Upload();//实列化上传类* s/ a1 X1 v. z+ t- m5 A
- $upload->maxSize=4145728;//设置上传文件最大,大小
' R$ _8 C& M. D9 A3 s - $upload->exts= array('jpg','gif','png','jpeg');//后缀
0 h6 P* o/ o2 c5 O - $upload->rootPath =$images_path;//上传目录: c; h) C' Q3 v+ I) j8 R$ V
- $upload->savePath = ''; // 设置附件上传(子)目录) r( {' C, F5 N+ }, c8 W; m8 v2 V/ _
- //$upload->autoSub = true;. X3 R7 A4 `9 g& D# f% {' r
- //$upload->subName = array('date','Ymd');8 U0 X6 _7 ?$ ^; U" c
- //$upload->saveName = array('uniqid','');//设置上传文件规则
) z. i4 I' `: I0 ]3 ~# u - $upload->replace = false;* n: G W: U5 c. W% Q k4 M
- $info= $upload->upload();//执行上传方法
# y% ?2 P; S8 Y y$ z - if(!$info){
# ~8 A3 N" v, G& Y9 m7 ~* A% f( w$ v; l - $res['status'] = 0;* a( A2 z. @$ W" |7 ^
- $res['res'] = $upload->getError();
/ K* w6 F) ^$ Z! X) n -
2 Z1 S/ |" \0 Z+ m - }else {2 ]- m5 J3 W( F) ^' [
-
: S. ]- ]9 e3 ~( u$ b0 ] - //获取上传文件信息
2 D% S8 Z. ^" W8 D: [' o0 j+ C0 [ - foreach ($info as $file){
' r. `' r2 C2 O% e5 ~+ X, r - $img_path[] = '/Uploads/image/shop/'.$file['savepath'] . $file['savename'];
/ e$ t+ i9 w0 {+ F! i( L. z0 Z - $name[]=$file['key'];
/ o) ?3 E$ z$ Z) k6 s
; z% {4 h& ]( G; x) g% J-
) o3 S" p4 s6 K7 ^. T1 T9 g - }
$ r" N2 `4 g* P+ \. Y - //图片物理目录删除、改名图片用
' j7 V' b- ?6 F- I+ L0 E9 J - $bigimg=$file['savepath'].$file['savename'];
( f% T! k3 G$ W - //$_POST['goods_big_img']=$bigimg;$ c8 H3 C" ?! S: \/ ^% F
-
$ u' Z5 c6 F5 c# z6 Y" E g -
$ H- ^1 J+ k! l3 q# i3 t) e - $image=new \Think\Image();. N" S' B- o. g9 v s. R
- # E8 Q3 O ~" Q& e1 y7 U: W
- $srcimg=$upload->rootPath.$bigimg;# J- ]( q$ ^' b
- $image->open($srcimg);+ p; s, N( I" {) z$ G' z
- $image->thumb(500,500);
/ H' J7 }: C& d+ }1 _) k- G" D - $smallimg=$file['savepath']."small_".$file['savename'];4 P4 B" A$ B/ E. I) T, K
- $image->save($upload->rootPath.$smallimg);
4 g9 v- y' l- h, y2 X$ o% S( M - //$_POST['goods_small_img']=$smallimg;
. `1 Q* _! c$ }8 [$ K g -
H# }' ]8 s* b* k. \8 d - ! `. P* h6 k: t
- ! U) g; Z6 }7 W5 [
- if ($path_old && $img_path) {# e& h$ h @/ }; q
- unlink('.' . $path_old);5 q+ {) e: f1 W7 S
- }
* E! N6 t# c) d5 @ - & _ e( ^; C( R* t' R6 E- W
- : g! m' c. r: z$ t
- $res['stats'] = 1;
, s" B' {" Z3 T - $res['res'] = $smallimg;" m4 a. y0 n( f- r4 W2 |
- $res['name']=$name;" p7 R& F8 ~ L ?
- }- ?+ p; A! d; J# R
- ( B; Y. s+ X5 b
-
, v: @! b' o6 p6 Y) W. q, r0 k - }
复制代码 9 c8 N4 Y' N4 V/ B
; E9 Y- Z- |" c- K8 R
|
|