<?php
" n! p$ a$ a4 [0 W( z4 k$ B+ n/**" I) t" Z2 a- X8 I
* uploadFlash.php+ U- w- \2 W; Y" U( q
* Flash文件上传.7 V8 x4 }8 X, M7 C! q$ { H) q
*/ v3 b3 d+ E8 L* f6 R4 t
require_once('../global.inc.php');
/ C( _) O& T$ ~$ _0 D, F) X' v4 L0 N6 t- L$ I! n5 c
//operateId=1 上传,operateId=2 获取地址.
/ }1 P: r4 W) ]" N$operateId = intval($_REQUEST['operateId']);: D& o- w+ e( l1 D& A
if(empty($operateId)) exit;
# ^) g; |3 W2 |& B
9 {% \ E! g1 ~0 i+ L. x Rif($operateId == 1){
% h0 j4 |$ S* d0 y, ~* H5 Q; o $date = date("Ymd");
+ m0 k8 s; |6 p- P, I, F( ~ $dest = $CONFIG->basePath."data/files/".$date."/";
7 X. i8 E) F! K& k $COMMON->createDir($dest);, W$ B4 c+ f3 w% `
//if (!is_dir($dest)) mkdir($dest, 0777);
; m! U7 v; Z, C4 u$ v
5 t8 E7 H3 C: ` $nameExt = strtolower($COMMON->getFileExtName($_FILES['Filedata']['name']));& e$ P0 `( Y8 b% T2 V
& Q- \4 O3 ]1 U
$allowedType = array('jpg', 'gif', 'bmp', 'png', 'jpeg');& C( u6 D& A1 C5 R
8 C: |0 F3 Y1 s# b7 n2 H" X
if(!in_array($nameExt, $allowedType)){
. f% M: @# _" E* } $msg = 0;
% U: n; D1 b. } a( L& ?0 c8 I" C }3 S( v, \# T) J! \ {6 {
if(empty($msg)){
& ]0 j9 ]/ v' A $filename = getmicrotime().'.'.$nameExt;4 u9 h8 G, ]7 I' o3 N$ i
$file_url = urlencode($CONFIG->baseUrl.'data/files/'.$date."/".$filename);3 A& y3 C7 Z' m7 N5 c! H
, e9 }/ K- K" n) U
$filename = $dest.$filename;8 W n5 L& A9 t) X" x& X
if(empty($_FILES['Filedata']['error'])){% m6 q5 [. n4 E$ v+ d) T
move_uploaded_file($_FILES['Filedata']['tmp_name'],$filename);
- g7 a9 o. J X2 G/ Z2 w7 n! c }; ~! Y; u$ i3 Z; L& V
1 l3 f+ a; c3 H" T( b' j if (file_exists($filename)){
3 S# b5 @; R0 x `* T4 d: J2 a //$msg = 1;
5 S2 {, v1 g5 E" ] P $msg = $file_url;' k0 o! k4 L0 E
@chmod($filename, 0444);
1 i# o& d- d; r$ d }else{0 L2 X& |7 w& i6 X
$msg = 0;4 p1 E* T: [+ V2 q1 I
}* A+ s3 ]) C7 B9 k! h8 ~
}& O' R+ |* ~5 q6 t- _( W
$outMsg = "fileUrl=".$msg;
: _& y$ x% o! K0 c: o e$ k $_SESSION["eoutmsg"] = $outMsg;
2 V$ }! C% D/ b& G$ q+ Z exit;
/ v, ?& e% k) i2 c- P% X}else if($operateId == 2){# c& w* I3 y: E1 a* r
$outMsg = $_SESSION["eoutmsg"];# k u9 U' v8 r
if(!empty($outMsg)){& m6 P: U5 z8 w
session_unregister("eoutmsg");/ ?8 k0 j1 ^5 B6 x
echo '&'.$outMsg;
' ~( X c4 L! L5 v: [, m exit;- Q( f: J5 V2 t# @$ a
}else{
/ J( B& ]1 H5 } echo "&fileUrl=0";
: R( j1 x7 A$ x; C8 j exit;
' e2 Z2 P1 m9 j3 X9 L }, o" n9 ^: H( u
}
7 a, B! K3 m# F, m2 a# U$ u% R8 Y( h3 N1 ~. b
function getmicrotime(){ & U4 k; c: v0 U
list($usec, $sec) = explode(" ",microtime());
, g0 Z2 r) X+ y3 i `3 a) V5 @ return ((float)$usec + (float)$sec);
" f, q, K0 e; q}3 H/ W7 p7 J) x) [! O* _, T0 O
- H3 y4 a9 v e% E- H `1 S
?>- J. F% d0 c! a1 n" E6 @: z
|