管理员
![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){4 D4 v& B+ l/ ?
- . r) c, F/ @0 L
- $images_path = './Uploads/image/shop/';$ {8 q2 } H3 `) `
- if (!is_dir($images_path)) {
& z4 n% d8 l) o - mkdir($images_path);
1 P) m# v/ {: ]; I, [9 m q - }
! E8 @# T5 N; k/ ~# Z' o; v4 s - 2 B; g" O$ S# ?5 F3 @: j8 r. u
- ! C# U5 ] U( j0 f( M5 m
- $upload = new \Think\Upload();//实列化上传类
% }# d# [7 h+ Q* ^* w( y8 z2 ] - $upload->maxSize=4145728;//设置上传文件最大,大小: }& m7 `; S- j2 c
- $upload->exts= array('jpg','gif','png','jpeg');//后缀
; T; ^: u* p; C - $upload->rootPath =$images_path;//上传目录9 a' B2 y. o* X; w0 m7 p
- $upload->savePath = ''; // 设置附件上传(子)目录
2 ^4 t. Z4 R& B( A% |9 N( x - //$upload->autoSub = true;2 n+ b) R/ W0 V! | K w
- //$upload->subName = array('date','Ymd');$ S# H! }% Y# W/ q1 a
- //$upload->saveName = array('uniqid','');//设置上传文件规则
' q0 j, y* \8 \, D n r( q - $upload->replace = false;" b1 ? \' B b. K4 ~" W( G
- $info= $upload->upload();//执行上传方法
1 n5 f/ n$ z. b( V# }2 n - if(!$info){
+ ~% E. ^) _2 Y$ V0 t - $res['status'] = 0;
( g) u0 o1 @6 C: P" O - $res['res'] = $upload->getError();' ?/ _) r1 r. j
-
+ \9 q. J v/ Q/ p6 Y& ^; @. f& R - }else {
" c7 z; F5 {& N/ T+ q" E' | - 0 i& J6 J* T! Q6 N# Y( O
- //获取上传文件信息) Q+ W; ~" K& m- s2 _1 c
- foreach ($info as $file){
4 S* v) t, {" ^7 X h! {; d - $img_path[] = '/Uploads/image/shop/'.$file['savepath'] . $file['savename'];
& ?, ?3 o5 R% L - $name[]=$file['key'];! j& Z+ [8 m, `6 X' Z
- ?, p$ Q. L( y j& d6 T- 8 k2 S# j3 v3 } t# N9 C" @$ v
- }' ^ A3 N4 r* h6 n% G$ u% h
- //图片物理目录删除、改名图片用) Y8 F- X9 E- w( L9 n {; ^
- $bigimg=$file['savepath'].$file['savename'];
1 x5 Z0 @: x+ c0 g' W - //$_POST['goods_big_img']=$bigimg;
6 \" O5 M) B+ K {- m - + ^( H0 { y: B- v/ k, w5 c
-
# Y- {$ n2 x! } - $image=new \Think\Image();1 z1 v1 \; I9 U6 g
-
9 c) ]7 j: H! ]4 G F! p1 Y* Q - $srcimg=$upload->rootPath.$bigimg;$ d% w1 @7 z0 D, ?) f ~+ F2 @+ r
- $image->open($srcimg);
2 a) ^; s5 Z: c4 u - $image->thumb(500,500);' m5 @" a( R% V
- $smallimg=$file['savepath']."small_".$file['savename'];! Z$ b2 Z! Z) i0 H# k
- $image->save($upload->rootPath.$smallimg);. R; ] W/ Z( \$ X! p6 O
- //$_POST['goods_small_img']=$smallimg;# o& w# f% w9 c8 o( X$ z
-
2 _" R! L9 i4 W - ' R9 v+ p) x" C1 c: T' i' y) B
- # u( g: r3 S$ F* \) L
- if ($path_old && $img_path) {) e" m- u3 c6 g6 p1 y6 I9 o
- unlink('.' . $path_old);* R0 B( D0 E; B5 R" W
- }/ k5 t' n* X& Q; @$ O1 ^
- ! j9 [( q# m+ d2 G q% T% B
- & L" ?5 e9 @/ _; Y. S+ U& K
- $res['stats'] = 1;- c4 j1 R" `& K! l6 Y
- $res['res'] = $smallimg;
: b9 J( p' B8 E) F8 B/ I" @ - $res['name']=$name;
6 j9 \; Q1 w$ Q( J% ^( H" N. W9 V - }
' g1 O1 p/ T" C2 u - 1 r3 S4 n* d6 V
-
8 J, S" m( d+ _0 V# g- x1 G% Q - }
复制代码
+ V8 |, @# L6 e) t1 V
; C3 b% Y% {1 {( O |
|