管理员
![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){
) S( Z/ g! u- f2 W - T: d% y+ y) Y0 Y3 N9 S4 ?
- $images_path = './Uploads/image/shop/';; q+ Y) p' Z! |7 e0 l* O# L
- if (!is_dir($images_path)) {' V8 ]! ?6 X7 N" g7 Z( S
- mkdir($images_path);2 ]& N Q. k( v" z. m/ ^! \+ P
- }
5 v! k; N- @) X6 \% O) L -
* R8 R w9 G; p
; T9 \1 x& B% o. h7 V( |7 V( f# s% R- $upload = new \Think\Upload();//实列化上传类% A! h6 J( F) P% Q' M! [
- $upload->maxSize=4145728;//设置上传文件最大,大小9 i& ]; U# h: J" M1 G' ?: l3 l
- $upload->exts= array('jpg','gif','png','jpeg');//后缀
+ a9 Y9 e( c1 U9 P8 S ~; S7 E; n/ { - $upload->rootPath =$images_path;//上传目录! _% T7 Y$ T) k
- $upload->savePath = ''; // 设置附件上传(子)目录
& _' [! F& V6 B# ] - //$upload->autoSub = true;
0 M U3 B3 b5 T6 D s) s - //$upload->subName = array('date','Ymd');( o" Q4 V9 J9 E
- //$upload->saveName = array('uniqid','');//设置上传文件规则
+ I4 L" X' k J% b( j - $upload->replace = false;* s+ ^# u* ^2 w# _$ ~1 G
- $info= $upload->upload();//执行上传方法
; p. `( |; M! q+ d5 s! Y/ t0 { - if(!$info){
; E7 E# S6 K/ O - $res['status'] = 0;) {; t o, A- S2 ?0 x q
- $res['res'] = $upload->getError();
' r, A8 I3 d! P( A" P - 0 W1 P% h/ n" U
- }else {! p- I. J+ o) Z
- + s9 j: d: {7 F0 f- \6 Q
- //获取上传文件信息/ | }2 N1 K3 i! Z( h) Z* _6 f9 F
- foreach ($info as $file){
& D; x0 ~% b% c& [ _# [ - $img_path[] = '/Uploads/image/shop/'.$file['savepath'] . $file['savename'];" J1 A0 {' a9 ~* k( \# Z9 w
- $name[]=$file['key'];4 n7 Y+ w6 u9 D# q3 }3 a
- ! Y$ R! Q7 ]# B& v8 V
-
$ U$ s: \* u7 H8 R; I! s5 z+ W - }
; Q# x9 U; V" n6 v - //图片物理目录删除、改名图片用
6 e: L& ~2 D5 w+ L1 y1 a - $bigimg=$file['savepath'].$file['savename'];( L/ l3 G8 S$ W& U
- //$_POST['goods_big_img']=$bigimg;
$ o1 U, v8 a' B1 i -
6 m6 [6 h: `+ n& Q9 y4 j - ; L) c. k! l; O3 A/ r
- $image=new \Think\Image();
2 ]9 f# C: Z+ s1 l - / r6 |" G! S( d! A" v, u
- $srcimg=$upload->rootPath.$bigimg;8 T! g8 X5 ~3 u- D
- $image->open($srcimg);7 R. r/ b K/ A' ^0 z j6 L( R
- $image->thumb(500,500);$ x i, _/ [& v( L: x* ~
- $smallimg=$file['savepath']."small_".$file['savename'];" P0 O# O& n9 e! a' Y
- $image->save($upload->rootPath.$smallimg);- V4 _5 E1 }# N" ~! t' i
- //$_POST['goods_small_img']=$smallimg;
$ K7 T: {3 S, z1 S4 J0 N- [/ } - $ y, p" z3 W; W* Y1 n. c
# w- A9 O) r/ C( C8 F7 r-
, R6 z, S# {- e+ C o9 N+ O4 Q - if ($path_old && $img_path) { G1 S! O9 \) h' J) \
- unlink('.' . $path_old);
3 R2 S# |, o: T1 T6 ?! _4 i4 W; r - } W5 l3 p: u% S& E- v$ H3 L2 O
- $ u" d+ U0 a+ a
-
' t. J: R5 l/ _, c" H2 j - $res['stats'] = 1;
y; ?; w V0 I+ v% | - $res['res'] = $smallimg;
0 P4 m7 n5 @1 P3 A - $res['name']=$name;$ \+ M/ i' r$ A0 _
- }% q9 |5 D0 o( ^. h! n0 b! R
-
$ w8 O! w! ^; c# f ` -
1 \% V: H) i& b9 O6 V& h W7 ? - }
复制代码
. I5 B3 B, c4 |; {) I# k
8 Z# o( `2 t; X0 S' P! R5 D) h0 p' I |
|