-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathringupload.php
More file actions
66 lines (56 loc) · 1.82 KB
/
ringupload.php
File metadata and controls
66 lines (56 loc) · 1.82 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/**
* 上传壁纸接口
*/
session_start();
header('content-type:text/html;charset=utf-8');
header ("Cache-Control: no-cache, must-revalidate");
require_once ('public/public.php');
require_once ('lib/WriteLog.lib.php');
require_once ('tasks/ring/RingDb.class.php');
require_once ('tasks/ring/RingFile.class.php');
try {
$name = isset($_POST['ringName'])?$_POST['ringName']:"";
$author = isset($_POST['author'])?$_POST['author']:"";
$note = isset($_POST['note'])?$_POST['note']:"";
$type = (int)(isset($_POST['type'])?$_POST['type']:0);
$input = "ringfile";
$error = $_FILES[$input]["error"];
$f_name = "";
$f_size = 0;
$f_tmp_file = "";
$result = get_file_info($input, -1, $f_name, $f_size, $f_tmp_file);
if($result != UPLOAD_ERR_OK){
Log::write("ringupload::get_file_info() failed ERRO NO: ".$result, "log");
$_msg = "上传失败";
echo "<script>window.parent.Finish('".$_msg."');</script>";
exit;
}
$ring = new RingDb();
$ring_file = new RingFile();
$url = "";
$md5 = "";
$id = "";
$result = $ring_file->ringUpload($error,
$f_name, $f_size, $f_tmp_file,
$type,
$url, $md5, $id);
if($result != UPLOAD_ERR_OK){
Log::write("ringupload::ring_file->ringUpload() failed ERRO NO: ".$result, "log");
$_msg = "上传失败";
echo "<script>window.parent.Finish('".$_msg."');</script>";
exit;
}
$ring->setRingParam($id, $type, $name, $note, $f_name, $url, $f_size, $md5, $author);
$result = $ring->insertRing2DB();
if(!$result){
Log::write("ringupload::ring->insertRing2DB() failed ", "log");
echo get_rsp_result(UPLOAD_FILE_ERR_DB);
exit;//记录失败并通知客户端
}
$_msg = "上传成功";
echo "<script>window.parent.Finish('".$_msg."');</script>";
}catch (Exception $e){
echo get_rsp_result(UPLOAD_FILE_ERR_EXCPTION);
exit;
}