<?php
# a, y0 c; d3 z$ v# u y/**
2 t+ K: X- N6 j) u) C8 I * uploadFlash.php2 {: y8 q5 b; B' h
* Flash文件上传.
( N) {7 ]9 U' k$ b. Q */
# i+ |6 [! [8 ?# q: k) `4 crequire_once('../global.inc.php');0 G) T" D2 V2 A
: V- Z a( I" b! t2 U- z//operateId=1 上传,operateId=2 获取地址.
1 U+ U( d1 C! |) n$operateId = intval($_REQUEST['operateId']);7 j5 r9 f$ y5 V W1 ~. j
if(empty($operateId)) exit;2 n* G8 S: X( I/ |
6 C8 Y" I Z/ K0 d: U, Aif($operateId == 1){
2 F. p3 L" j1 a! G f $date = date("Ymd");4 a3 j. z+ W* \& L \
$dest = $CONFIG->basePath."data/files/".$date."/";8 I! C. ^1 v* Q/ V# F5 \
$COMMON->createDir($dest);
& h, H3 t0 m, [: E" r( c# V3 M //if (!is_dir($dest)) mkdir($dest, 0777);3 r- g+ h8 h: Y; {8 E1 _6 h/ b
' x5 J- C9 ~6 I
$nameExt = strtolower($COMMON->getFileExtName($_FILES['Filedata']['name']));
: P# q: U2 e% }: M + F% M8 w9 Y9 [' Y8 |$ e2 M
$allowedType = array('jpg', 'gif', 'bmp', 'png', 'jpeg');( @5 v* H/ W. k8 t; u6 e
8 O1 h4 R3 v- _) I7 O4 N$ P if(!in_array($nameExt, $allowedType)){
! d3 c& D0 `" Q$ D9 n0 _8 Q $msg = 0;$ M+ I$ Z: Y- b
}
r( {' F5 e. o- ~ if(empty($msg)){' }( V* F+ B1 J
$filename = getmicrotime().'.'.$nameExt;6 R% s) E3 r2 [4 B$ T9 H9 X
$file_url = urlencode($CONFIG->baseUrl.'data/files/'.$date."/".$filename);( x$ p5 J& Z9 @3 l
6 x/ k1 @! a5 l {3 a $filename = $dest.$filename;, k* p$ r$ _( ~
if(empty($_FILES['Filedata']['error'])){. K4 j8 \& B5 J# d$ J' @
move_uploaded_file($_FILES['Filedata']['tmp_name'],$filename);
/ i3 g; t9 ]9 d1 X }/ W. Q. P/ I0 L
& Z: j7 Z: u, h, a9 }1 h e
if (file_exists($filename)){
% |5 `% N: w9 [! k* Y //$msg = 1;
- k/ J* z6 C$ o7 Z1 b: T2 ` $msg = $file_url;
/ `) t* M7 w0 ~; \' K2 J5 Z @chmod($filename, 0444);5 v5 }" F# P1 v/ `! B1 ~2 M5 ?/ K
}else{" C' w6 l4 |8 y
$msg = 0;0 C$ R4 J7 R1 Y: F! ?6 I" l. L$ B
}
" c# |: i# h0 A5 ` }
7 s* \, F, v1 U7 [5 O+ b $outMsg = "fileUrl=".$msg;
, L& v. E9 P/ O8 Z $_SESSION["eoutmsg"] = $outMsg;
: u# m* X. n- C exit;
! L' b0 B; ]/ E2 V}else if($operateId == 2){( S u0 u/ Y1 d8 |- q
$outMsg = $_SESSION["eoutmsg"];- ^2 w; a+ p3 @
if(!empty($outMsg)){7 `( z. o# u6 @6 B0 t" U1 b! b ]: V0 d
session_unregister("eoutmsg");4 a3 w6 X& u! [/ S
echo '&'.$outMsg;
* u* z, R! W1 f+ H4 T. g6 q exit;
$ S9 h& u1 h; N" p2 P0 L6 ~' S }else{
+ A# ~( [- {4 z! ?9 F; p' V/ n echo "&fileUrl=0";
% j2 f0 k) j2 }! u+ D" h, ? exit;5 `0 H5 t1 d( ?+ w# v! F: k
}
- b, V. n2 i) _; a4 p( J/ C}
* K$ A) S n& ^ J3 E, v$ R! ?$ `) q! d S T/ T
function getmicrotime(){
# }. Y& E+ ?3 U2 H b: j1 r1 h list($usec, $sec) = explode(" ",microtime()); 5 S& }1 B: E& F% N/ e( s; [- w" R
return ((float)$usec + (float)$sec);
5 I. G0 W# g$ q: O}
/ k$ A! V, z; O# P0 x2 B9 g( Q/ o% t S! X: f* a0 r. ]
?>) w$ y4 i% n) U: Y
|