-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.php
39 lines (28 loc) · 1012 Bytes
/
upload.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
$F = $_FILES['filedata'];
$ajax = isset($_GET['ajax']) ? $_GET['ajax'] : "";
$jsoncallback = isset($_GET['jsoncallback']) ? $_GET['jsoncallback'] : "";
//print_r($F);
if( $ajax && isset($_GET['uploadID']) ){
//获取文件尺寸
//$status = apc_fetch('upload_' . $_GET["uploadID"]);
//apc_fetch('upload_'.$_GET['uploadID']);
//$status['done'] = 1;
//echo json_encode($status);
$status = apc_fetch('upload_'.$_GET['uploadID']);
echo $status['total'];
}else{
//apc_store('upload_' . $_GET["uploadID"], $F);
//$status['done'] = 1;
if( $F["error"]==0 ){
//上传成功
move_uploaded_file($F["tmp_name"],"upfile/" . $F["name"]);
//print_r($F);
$data = "{'status':1,'msg':'上传成功!','uploadID':'".$_POST["uploadID"]."','file':'/upfile/" . $F["name"] . "'}";
if( $jsoncallback ){//表单上传
echo "<script>parent." . $_GET['jsoncallback'] . "(" . $data . ");</script>";
}else{//xhr异步上传
echo $data;
}
}
}