<?php
- M; A) g+ Y( V$ j8 e$ c. ?( d/**
. @2 Z' p m4 t! [5 e' f" x * uploadFlash.php" }5 g( h: B( K" P* V5 }4 t
* Flash文件上传.6 _4 ]# H" z' ?/ }( P7 P
*/& p, p! p" m( y
require_once('../global.inc.php');- Y2 J4 x% [/ m0 K9 i* Z
6 \( h7 S) n3 L2 @+ \, S7 g
//operateId=1 上传,operateId=2 获取地址.7 m6 |# b- S2 t* b& w
$operateId = intval($_REQUEST['operateId']);+ I. a- ^0 r1 C* [ j) _, ~
if(empty($operateId)) exit;
7 c( Z# f. Q E, z7 H
% Q: Z% g( h' e' Cif($operateId == 1){& ~& K1 V; D* l. U+ L! v! l) U
$date = date("Ymd");
5 O# F" x# @& z' S $dest = $CONFIG->basePath."data/files/".$date."/";
2 d( U" G+ `! r" _& b1 Y7 H# i $COMMON->createDir($dest);0 m/ B$ b; ~6 ]& t. B( O+ V0 c
//if (!is_dir($dest)) mkdir($dest, 0777);
* M9 ?1 u, @ x/ z2 p' a e 7 z: m5 H+ ]: T- G( t
$nameExt = strtolower($COMMON->getFileExtName($_FILES['Filedata']['name']));
; [/ Y* k. O; Q; h/ P% T) R( u1 Z, T$ k
) c* }6 r6 C w" i q2 A1 \ $allowedType = array('jpg', 'gif', 'bmp', 'png', 'jpeg');) l% v5 i0 l( N8 y0 _3 N
# {- x0 B k% V8 \1 u: f1 P' V
if(!in_array($nameExt, $allowedType)){3 J) |+ z2 c9 N
$msg = 0;
! q. k* r+ r3 K' s: t3 k* @0 u }
4 T# d4 U* Z4 K9 r" P if(empty($msg)){
9 `6 w- ?# h6 `5 C5 c% { $filename = getmicrotime().'.'.$nameExt;7 H8 ^! M+ Z) @9 n
$file_url = urlencode($CONFIG->baseUrl.'data/files/'.$date."/".$filename);; @; L+ r$ W+ `0 l( {# W
" s" x% ?4 h" g; ~
$filename = $dest.$filename;, `8 S, e7 |- I0 {$ z: S
if(empty($_FILES['Filedata']['error'])){5 U& |" F9 B* X* u% v1 Z
move_uploaded_file($_FILES['Filedata']['tmp_name'],$filename);7 e3 B2 n2 J" y( l
}
- E; m* i7 U/ ]. `; l: I * V% f6 z# @9 ?- F& |
if (file_exists($filename)){
2 G5 d0 j4 s) {/ O //$msg = 1;
1 P5 y; W+ R- q, _0 L $msg = $file_url;7 l8 E0 e8 H! a) X3 _, L) s B3 l
@chmod($filename, 0444);+ s% h6 G: [$ T9 Q+ d- w$ W$ F
}else{
; q! i, D% z' f) W5 `- ` $msg = 0;" e$ A2 z; `) @
}) }; B% S$ X9 J
}
3 j; _. c- Q3 U" m+ @' z7 s $outMsg = "fileUrl=".$msg;
6 y' @" s0 _) W$ _$ x $_SESSION["eoutmsg"] = $outMsg;
6 h9 m+ @0 D) @ exit;% ~/ _$ \" w" G
}else if($operateId == 2){/ z+ E7 ~$ {# q) }0 J( I. Z* R' b
$outMsg = $_SESSION["eoutmsg"];- e7 K' K: n+ T" X4 y" T6 ~/ j
if(!empty($outMsg)){
( d. N8 ]- x# ^$ ? session_unregister("eoutmsg");
, L; C. Z) m- l echo '&'.$outMsg;6 C. b2 C! y/ }/ ^) Y; W
exit;
% f! ^8 S+ z* T$ d( S. [3 q }else{2 f6 B; J/ E3 V
echo "&fileUrl=0";
3 p9 y* J ~$ |1 P2 W( r, J exit;+ w! M/ ?( c2 t4 W3 u' T- a
}
5 M2 b, b8 P& l* l}
- Y0 n% |9 q+ V8 m; k2 L/ X( Y9 X! S2 l. w f
function getmicrotime(){
/ K1 d4 P G/ c$ D u7 I list($usec, $sec) = explode(" ",microtime()); 2 G& O4 j# [" j. Q
return ((float)$usec + (float)$sec);
& i$ r$ v- E$ U8 P# a}' I# t/ @; |1 Q4 ?/ Q8 I% u& h
& W# r( N( T1 ]
?>
8 ~5 C8 O. x4 n) O: ?, k6 P |