-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost.html
More file actions
51 lines (49 loc) · 1.88 KB
/
post.html
File metadata and controls
51 lines (49 loc) · 1.88 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
<?
const {importHead}=globals.functions;
?><!DOCTYPE html>
<html>
<head>
<?=importHead({
input,
title:"Try Post!",
script:[],
tabs: 2,
})?>
</head>
<body>
<h1>Post</h1>
<form method=POST enctype=multipart/form-data>
<p><input type=file name=file></p>
<p><button>POST!</button></p>
</form>
<?
delete input.body
const tabs="\t\t";
let html="";
if(input.file!=undefined){
const file=input.file;
html+=`${tabs}<p>Datei-Name: <slim style=color:green>${file.filename}</slim></p>\n`;
html+=`${tabs}<p>Datei-Größe in Bytes: <b>${file.data.length}</b> B</p>\n`;
html+=`${tabs}<p>Datei-Größe in KiloBytes: <b>${Math.round(file.data.length/1024*1e3)/1e3}</b> KB</p>\n`;
html+=`${tabs}<p>Datei-Größe in MegaBytes: <b>${Math.round(file.data.length/1024/1024*1e3)/1e3}</b> MB</p>\n`;
html+=`${tabs}<p>Datei-Größe in GigaBytes: <b>${Math.round(file.data.length/1024/1024/1024*1e3)/1e3}</b> GB</p>\n`;
html+=`${tabs}<p>Datei-Type: <slim style=color:green>${file.type}</slim></p>\n`;
if(
file.type.startsWith("text/")||
file.type==="application/x-javascript"
){
html+=`${tabs}<textarea style=width:100%;height:300px>${file.data.toString("utf-8").trim().split("\r").join("").split("\n").join(" ")}</textarea>\n`;
}
else if(file.type.startsWith("image/")){
html+=`${tabs}<img alt="${file.filename}" src="data:${file.type};base64,${file.data.toString("base64")}">\n`;
}
else if(file.type.startsWith("video/")){
html+=`${tabs}<video controls autoplay width=100% alt="${file.filename}" src="data:${file.type};base64,${file.data.toString("base64")}"></video>\n`;
}
else if(file.type.startsWith("audio/")){
html+=`${tabs}<audio controls autoplay width=100% alt="${file.filename}" src="data:${file.type};base64,${file.data.toString("base64")}"></audio>\n`;
}
}
?><?=html?>
</body>
</html>