<?php
9 {2 |0 R( w; \( Y( l/**
* S. P% s) e4 N4 A C. J5 S6 @ * uploadFlash.php
1 h0 V2 ]; F2 V1 L, [( Y5 C5 \ * Flash文件上传.
/ ]4 I6 j1 }9 @2 W+ J */
4 u( q- T5 W- C3 \0 I0 J$ wrequire_once('../global.inc.php');) C0 n! `0 V* L
+ Q: T6 n3 X) F, E//operateId=1 上传,operateId=2 获取地址.
- T9 i7 D' {: @$operateId = intval($_REQUEST['operateId']);/ Q9 @- y0 t5 z$ h: e g1 m
if(empty($operateId)) exit;6 o% t8 Y7 ?3 c, Y( r/ `
; M& n& i3 j2 C( d A* nif($operateId == 1){
' K {* x( C( E) k! L7 q* ~ $date = date("Ymd");
$ z& B" F/ c$ V4 `7 e $dest = $CONFIG->basePath."data/files/".$date."/";
* P+ Q2 Q1 |; U3 A- q $COMMON->createDir($dest);/ l8 k7 o: F. R# G( I7 V8 t
//if (!is_dir($dest)) mkdir($dest, 0777);9 r0 C8 f/ X% @
6 F& Z3 q) ?" {: K* u $nameExt = strtolower($COMMON->getFileExtName($_FILES['Filedata']['name']));! q5 `3 \) F7 c3 ~
. Q* q Y i; W% _$ {4 L. _/ _ $allowedType = array('jpg', 'gif', 'bmp', 'png', 'jpeg');$ Y2 `" ^+ @/ w3 }
0 P/ e. h; w2 [+ X t9 P" M if(!in_array($nameExt, $allowedType)){, ^ u- L% h2 M6 J' d9 U. y* i. }
$msg = 0;; o3 C& M: h# K( s+ i/ h& A- R) H9 I
}/ M! X: {8 r7 B
if(empty($msg)){
: D+ t) t4 N( i6 n% Y& c $filename = getmicrotime().'.'.$nameExt;
3 n9 P ~6 k6 x$ h0 D $file_url = urlencode($CONFIG->baseUrl.'data/files/'.$date."/".$filename);
1 ]1 [& N$ h: V3 \& o
5 Q; F* c; _( n' F $filename = $dest.$filename;: _) w, L( h' c7 l
if(empty($_FILES['Filedata']['error'])){& B' {9 B2 d8 E8 z9 h: c
move_uploaded_file($_FILES['Filedata']['tmp_name'],$filename);
' _9 F5 }6 o. t& n }" X7 W( }7 r' O6 ?; Q" ~4 g; s
( \. l5 m$ s% N# W8 `
if (file_exists($filename)){) s- }& g; l: L& R+ c: m8 F
//$msg = 1;
S- x o, k A $msg = $file_url;
8 [% k" D% A: V5 d @chmod($filename, 0444);
' ^3 v7 Q- i( C7 ] }else{' d4 {; U) b8 J: \! q) L- ^ P/ v
$msg = 0;
. l7 c; ~4 o5 ^" m! I! w7 f+ P& o( E } u6 \# d) o% o9 Y: E4 c" C, n" a, y
}+ X* `0 `, G* T1 `- U/ V' f" E' i
$outMsg = "fileUrl=".$msg;/ L! |; C, I; B* b3 n" U
$_SESSION["eoutmsg"] = $outMsg;
) X' Y6 C7 I% l7 I# _ exit;
( U( B1 O5 c% o `& `}else if($operateId == 2){* s& P; p& u' E/ v& P
$outMsg = $_SESSION["eoutmsg"];) {# \. z( }: V* D- e
if(!empty($outMsg)){
# C- \& X! I$ {; e x, ] session_unregister("eoutmsg");' ~0 P5 c" u; w
echo '&'.$outMsg;
: D$ a- R* |% o5 z exit;
3 n4 G: x3 s% u. q }else{
1 S) y/ z. g1 W" t; ]# U echo "&fileUrl=0";$ `5 Z+ z& B8 I* A1 J) i
exit;
. `& b* K) @. x9 B. w' ^6 `3 b# ^ } T% Q7 m# F( d7 P7 x2 d3 B6 A
}3 W0 n: I5 R: ^6 E. P3 [7 @; ]; D
( F; }3 f) |- ?! e* W+ F% O* f' O
function getmicrotime(){ & O' n9 q8 G7 `; S# `9 }# ~
list($usec, $sec) = explode(" ",microtime()); , L& M9 w& a2 R
return ((float)$usec + (float)$sec);
6 x) d; J: [( [( U0 _+ y}7 o7 F$ {/ E1 i: z, \' G5 O
$ Y! S. Z" }3 n# n
?>$ }0 M S1 r) D& I; q; o
|