<?php% l4 B4 M5 ]5 @# |9 {+ o
/**) Y( y& Y) }$ U6 J! Q2 v
* uploadFlash.php# t. L4 w1 k, X( Y$ @4 g' j6 x+ t
* Flash文件上传." T3 T: [. N; I H& h
*/
1 C8 M$ T. c7 Hrequire_once('../global.inc.php');# Y5 ?- R- U8 a: p
( _2 |: f% t/ N5 f k- f' L; H. L4 @
//operateId=1 上传,operateId=2 获取地址.
_0 W6 H1 S% m3 Q$operateId = intval($_REQUEST['operateId']);
. e/ }7 b/ q) s: uif(empty($operateId)) exit;8 R5 [; n. P; Q: ~
2 }$ s( ^* b( }7 E9 t/ W; eif($operateId == 1){
- c. `; \. {! S1 G; E $date = date("Ymd");
! @! V4 A, @% v" D: V4 O $dest = $CONFIG->basePath."data/files/".$date."/";
' c+ ~" j0 D d2 M6 o, ?8 Q $COMMON->createDir($dest);7 R! Y; @& e) N% a: i8 t. o
//if (!is_dir($dest)) mkdir($dest, 0777);
+ Q8 ^" o. m9 p. V2 X4 S+ f* K4 q. q
4 e4 |# s1 X2 U) B2 l& s $nameExt = strtolower($COMMON->getFileExtName($_FILES['Filedata']['name']));! V+ J% u; ], G0 y* k
' e6 B% S- J: Q' Y4 c; t2 X
$allowedType = array('jpg', 'gif', 'bmp', 'png', 'jpeg');1 _+ h/ k7 _/ I U4 n! S
- C/ [. p1 I1 o/ h! n
if(!in_array($nameExt, $allowedType)){
. v* k7 S/ }7 w% N1 K1 E $msg = 0;. y; C. a# Y7 ^" W8 |0 l, i
}$ D/ w$ l7 |$ e- F
if(empty($msg)){
9 q2 j* T2 w; `' | $filename = getmicrotime().'.'.$nameExt;: D+ S$ C0 d g
$file_url = urlencode($CONFIG->baseUrl.'data/files/'.$date."/".$filename);
& {- z ?0 J W+ Q ( R: W. J4 \* d3 c
$filename = $dest.$filename;
6 o( v9 Z+ `0 b8 M5 i% h; O/ ]) j if(empty($_FILES['Filedata']['error'])){
1 L3 N' h+ C( r, u8 p/ u move_uploaded_file($_FILES['Filedata']['tmp_name'],$filename);
( d C( V2 c- N/ V }3 j, Y& e/ }9 x* O) f0 `
% O" A; X1 C* ^6 B+ C Q" M
if (file_exists($filename)){
* N! B' f) v5 R) v. n //$msg = 1; ?# C' c% o" A, H! G, d
$msg = $file_url;0 v& X6 N4 x+ V) E- E
@chmod($filename, 0444);
! N4 f: m+ }/ q& J0 T }else{2 K/ G1 o$ F- i- b! C
$msg = 0;
$ b1 r6 O' }& @2 N; e- A }" Q. o, ~7 `& s/ B2 I- X8 Q
}4 z) M. M- G/ {6 |
$outMsg = "fileUrl=".$msg;% b6 X2 V( {) ~* Y/ n( a& o
$_SESSION["eoutmsg"] = $outMsg;
4 ]- Z) G9 H$ W0 E1 i/ C exit;+ k! O8 L" \9 j7 F$ Q
}else if($operateId == 2){
- _: C! t, F6 r# q" z3 i $outMsg = $_SESSION["eoutmsg"];
8 n! H9 ]9 o$ {. b2 U8 h if(!empty($outMsg)){
5 M& A4 T" C2 z8 y M session_unregister("eoutmsg");
8 L# a7 E( B; c echo '&'.$outMsg;
. H* p* x" }6 N1 t exit;0 M1 z; y) [- i! q$ N/ f8 g
}else{2 V1 z& J% ?' E9 e% l
echo "&fileUrl=0";
, Z( i2 [- o5 Q+ g$ v exit;
9 d3 g. i1 @7 \$ e/ {% Q- Q1 V- P1 a }
0 R9 T; ` X3 s0 l9 T- a" q}- W. ]* H; r' Q4 A+ q" O+ J
2 C/ { y' ^ Q- f9 J( c4 Afunction getmicrotime(){ B! _6 C$ a$ r5 X: D" ^* n" O# j
list($usec, $sec) = explode(" ",microtime());
% W5 c0 }' t; m; e4 }! x( K, i return ((float)$usec + (float)$sec);
7 z& f8 E/ z3 J" d0 ?% l( J}
& v% F4 W" y9 U0 y$ f9 n: T; T8 N4 y" u$ Z5 i \' f
?>
) I" L2 X$ s; _" v6 y. u |