管理员
![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){+ b8 }; L. ^; A' u0 w
- 8 O1 ~) z8 }$ k
- $images_path = './Uploads/image/shop/';; j+ [, L$ U3 O: N
- if (!is_dir($images_path)) {% u3 ^5 M Z l! O
- mkdir($images_path);' x/ g Y/ p" c4 ]
- } # w, J$ c2 y T2 g0 Y- D
-
s0 t/ T' o L, P3 B8 W8 K - 6 G" } R0 h$ T
- $upload = new \Think\Upload();//实列化上传类
: c- U; m: l3 a - $upload->maxSize=4145728;//设置上传文件最大,大小
' L' H! J! E* E( Q( o! w/ Y: [ - $upload->exts= array('jpg','gif','png','jpeg');//后缀
! e* l3 w# d; n' |0 T - $upload->rootPath =$images_path;//上传目录
9 c# {$ C9 M$ g* M7 a+ [1 D5 K+ P - $upload->savePath = ''; // 设置附件上传(子)目录' y, \0 G! O+ d: \+ m
- //$upload->autoSub = true;" }6 u0 n# r8 o+ D) E
- //$upload->subName = array('date','Ymd');9 \- J: E2 [5 p4 q% U+ b
- //$upload->saveName = array('uniqid','');//设置上传文件规则3 c+ D* X- V/ K6 a5 l Q% A+ T
- $upload->replace = false;
1 [6 D! P! a; w! C$ d8 l3 s - $info= $upload->upload();//执行上传方法5 b: ?8 Y8 N& r! G- H9 F
- if(!$info){
+ c( @2 d4 k. w) y - $res['status'] = 0;$ ]8 n/ v6 A3 c v) U- |
- $res['res'] = $upload->getError();0 n0 Z1 u% r. o4 b9 B1 b
- & a7 h* D A, X" ?
- }else {7 k: B9 U, c2 r0 p
-
3 S+ o8 W# l0 e5 r, D; A/ } - //获取上传文件信息
4 H! \1 K$ b, \; p0 @7 {8 b' a) Q - foreach ($info as $file){( D2 P$ I. v& R7 ]& k$ X h$ I* M
- $img_path[] = '/Uploads/image/shop/'.$file['savepath'] . $file['savename'];
) l' A* y8 ]( z2 {& H - $name[]=$file['key']; ^6 {' I# K& l" n! @1 | y X1 D6 N
- 1 h6 V/ y9 N( {3 e9 H Y2 k1 ]3 I; H
-
/ \+ [9 S( q% e! K+ W5 d - }
_( y7 z' B0 j* i4 r - //图片物理目录删除、改名图片用
. }. H E4 Z6 V; O a$ W+ P - $bigimg=$file['savepath'].$file['savename'];
& `4 x$ x1 T) U - //$_POST['goods_big_img']=$bigimg;9 z' G3 C2 {/ q$ Q$ ]2 {1 \
- 5 f+ [1 J# V' y; q
- , |0 _& {$ C. n2 T: s- T
- $image=new \Think\Image();: i3 @* m8 ^) d; }3 T9 f' O' o7 y
-
. o9 _3 {( G6 P/ D0 o7 s2 e* t8 V1 L - $srcimg=$upload->rootPath.$bigimg;
4 e/ l/ G8 |0 C0 c8 @ - $image->open($srcimg);
0 V7 M( f" j8 T+ O d2 I4 Z - $image->thumb(500,500);
5 _$ H' r6 F: l- D2 B - $smallimg=$file['savepath']."small_".$file['savename'];
3 o. d c- G4 g; k/ ? - $image->save($upload->rootPath.$smallimg);- j: ]# X/ ]* ~
- //$_POST['goods_small_img']=$smallimg;0 y V6 y/ C: q& @9 y
-
5 Y- A! U b7 p( d+ h - " S: I. w# R) u% R" U7 X
- ) j7 n% T7 f7 K- s" k8 D; W* k+ \( B0 o
- if ($path_old && $img_path) {+ V8 U+ [8 p1 K5 c
- unlink('.' . $path_old);
7 J1 Q! q5 ]! F8 U - }! B( p+ M' b% x, ]5 S6 t
-
! L& E: h9 w3 k& b -
' o* N' O, c+ J( K6 E' F' _ - $res['stats'] = 1;
+ M# P8 ?5 N: I$ A( b - $res['res'] = $smallimg;
4 B0 _ M( p& k. U - $res['name']=$name;' u* h, M1 |. |, [0 L
- }
; R4 |$ {! ^6 I) c8 K1 L -
" h3 K: l8 o( R$ f* @/ R - 2 F7 }: M7 [+ E Q9 i3 l
- }
复制代码
( \9 ^; u0 K$ Y4 @$ I( ^( k6 j* e
|
|