-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.h
60 lines (56 loc) · 1.51 KB
/
template.h
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
#define DOWNLOAD_HTML_HEAD_TEMPLATE \
"<!DOCTYPE html>\
<html>\
<head>\
<meta charset=\"utf-8\" />\
<link rel=\"stylesheet\" href=\"https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.min.css\">\
<title>Download</title>\
</head>\
<body>"
#define DOWNLOAD_HTML_TAIL_TEMPLATE "</body>\n</html>"
#define UPLOAD_HTML_TEMPLATE \
"<!DOCTYPE html>\
<html>\
<head>\
<meta charset=\"utf-8\"/>\
<title>Upload</title>\
<script src=\"https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js\">\
</script>\
</head>\
<body>\
<form> <input type =\"file\" id=\"avatar\" name=\"avatar\">\
<input type=\"text\" id=\"path\" name=\"path\" placeholder=\"上传路径,默认为/\">\
<button id=\"btn\" type=\"button\">Upload</button>\
</form>\
</body>\
<script>\
$('button').click(function(){\
var files = $('#avatar').prop('files');\
var path = $('#path').val();\
if(path === '') {\
path = '/';\
}\
var data = new FormData();\
data.append('avatar', files[0]);\
data.append('path', path);\
console.log(path);\
$.ajax({\
url : '/upload',\
type : 'POST',\
data : data,\
cache : false,\
processData : false,\
contentType : false\
});\
});\
</script>\
</html>"
#define ERROR_HTML_HEAD_TEMPLATE \
"<!DOCTYPE html>\
<html>\
<head>\
<meta charset=\"utf-8\" />\
<title>Error</title>\
</head>\
<body>"
#define ERROR_HTML_TAIL_TEMPLATE "</body>\n</html>"