-
Notifications
You must be signed in to change notification settings - Fork 4
/
upload.rsp
88 lines (83 loc) · 1.83 KB
/
upload.rsp
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<%
if any [
validate/full [
id integer! *
file - *
mode word! *
]
all [
params: request/content
params/mode <> 'add-file
]
][
print "access denied"
response/end
]
root: %public/files/
target: either file? params/file/2 [
file: split-path params/file/2
replace id: file/2 ".tmp" ".att"
if exists? join root file/2 [
random/seed now/time/precise
until [
pos: find file/2 #"."
file/2: join random copy/part file/2 pos pos
not exists? join root file/2
]
]
file/2
][
;-- create unique file name
id: make file! 12
until [
clear id
loop 8 [insert tail id #"`" + random 26]
insert tail id ".att"
not exists? join root id
]
id
]
request/store/as params/file join root target
sess: session/content
either negative? params/id [
if none? sess/files [sess/files: make block! 1]
repend/only sess/files [params/file/1 target]
][
add-file params/id params/file/1 target
]
if find [%.jpg %.jpeg %.png %.gif %.bmp] suffix? params/file/1 [
;-- make thumbnail
call/wait reform [
to-local-file %public/files/nconvert
"-out png -ratio -resize 64 64 -o"
to-local-file join root [target %-small.png]
to-local-file join root target
pick ["" "&> /dev/null"] system/version/4 = 3
]
]
;--- View version is missing a decent filter!!!
;
; if all [
; find system/components 'draw
; find [%.jpg %.jpeg %.png %.gif *.bmp] suffix? params/file/1
; ][
; img: load join root target
; ratio: img/size/x / img/size/y
; size: 64x64
; either ratio <= 1 [
; size/x: round/half-ceiling size/x * ratio
; ][
; size/y: round/half-ceiling size/y / ratio
; ]
; new: make image! size
; draw new [image-filter nearest image img 0x0 size border]
; save/png join root [target %-small.png] new
; ]
%>
<html>
<head>
</head>
<body>
File uploaded successfully.
</body>
</html>