forked from istoan/HTML5-Webcam-Photobooth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
save.asp
40 lines (34 loc) · 940 Bytes
/
save.asp
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
<%
if Request.TotalBytes>"" then
'Name of the folder
folder = "images"
'Generate unique ID
max=999999999
min=1
Randomize
id=Int((max-min+1)*Rnd+min)
'Generate file name
filename = "photo_" &id &".jpg"
'Open object used to manipulate binary data
set objStream = server.CreateObject("ADODB.Stream")
objStream.Type = 1
objStream.open
on error resume next
objStream.write Request.BinaryRead(Request.TotalBytes)
objStream.SaveToFile Server.MapPath(folder) &"\" &filename, 2
if err<>0 then
'Error saving image
response.Write(err.description)
else
response.Write(filename)
end if
objStream.close
'Clear memory
set objStream = nothing
id = vbnullstring
filename = vbnullstring
else
'No binary data received
response.Write "Encoded JPEG information not received."
end if
%>