Objcn.close
Set objrst=nothing
Set objCN = Nothing
%>
<!--#include file= "upload.asp"-->
Showpic.asp
----------------------------------------
<%
Set objCN = Server.CreateObject ("Adodb.connection")
Set Objrst = Server.CreateObject ("Adodb.recordset")
Objcn.open "Upload"
Objrst. Open "Select what from pic where id=" & Request ("id"), OBJCN
If not objrst.eof then
Response.BinaryWrite Objrst ("what")
End If
Objrst.close
Objcn.close
Set objrst=nothing
Set objCN = Nothing
%>
Upload.asp
-------------------------------------------
<%
Sub Builduploadrequest (Requestbin)
' Get the boundary
Posbeg = 1
Posend = InstrB (posbeg,requestbin,getbytestring (Chr (13)))
Boundary = MidB (Requestbin,posbeg,posend-posbeg)
Boundarypos = InstrB (1,requestbin,boundary)
' Get all data inside the boundaries
Do Until (BOUNDARYPOS=INSTRB (Requestbin,boundary & Getbytestring ("--)")
' members variable of the objects are put in a Dictionary object
Dim Uploadcontrol
Set Uploadcontrol = CreateObject ("Scripting.Dictionary")
' Get ' object name
Pos = InstrB (boundarypos,requestbin,getbytestring ("Content-disposition"))
Pos = InstrB (pos,requestbin,getbytestring ("Name="))
Posbeg = pos+6
Posend = InstrB (posbeg,requestbin,getbytestring (Chr (34)))
Name = getString (MidB (Requestbin,posbeg,posend-posbeg))
Posfile = InstrB (boundarypos,requestbin,getbytestring ("Filename="))
Posbound = InstrB (posend,requestbin,boundary)
' Test if object is of file type
If posfile<>0 and (Posfile<posbound) Then
' Get Filename, Content-type and content of file
Posbeg = Posfile + 10
Posend = InstrB (posbeg,requestbin,getbytestring (Chr (34)))
FileName = getString (MidB (Requestbin,posbeg,posend-posbeg))
' Add filename to Dictionary object
Uploadcontrol.add "filename", filename
Pos = InstrB (posend,requestbin,getbytestring ("Content-type:"))
Posbeg = pos+14
Posend = InstrB (posbeg,requestbin,getbytestring (Chr (13)))
' Add Content-type to Dictionary object
ContentType = getString (MidB (Requestbin,posbeg,posend-posbeg))
Uploadcontrol.add "ContentType", ContentType
' Get content of object '
Posbeg = posend+4
Posend = InstrB (posbeg,requestbin,boundary)-2
Value = MidB (Requestbin,posbeg,posend-posbeg)
Else
' Get content of object '
Pos = InstrB (pos,requestbin,getbytestring (Chr (13)))
Posbeg = pos+4
Posend = InstrB (posbeg,requestbin,boundary)-2
Value = getString (MidB (Requestbin,posbeg,posend-posbeg))
End If
' Add content to Dictionary object
Uploadcontrol.add "Value", value
' Add Dictionary object to main dictionary
Uploadrequest.add name, Uploadcontrol
' Loop to Next object '
BOUNDARYPOS=INSTRB (Boundarypos+lenb (boundary), requestbin,boundary)
Loop
End Sub
' String to byte string conversion
Function getbytestring (STRINGSTR)
For i = 1 to Len (STRINGSTR)
char = Mid (stringstr,i,1)
getbytestring = getbytestring & ChrB (AscB (char))
Next
End Function
' Byte string to string conversion
Function getString (Stringbin)
getString = ""
For intcount = 1 to LenB (Stringbin)
getString = getString & Chr (AscB (MidB (stringbin,intcount,1))
Next
End Function
%>
Test.mdb (DSN name: Upload)
----------------------------------------
Table Pic:
ID: Auto Add
FileName: Text
Type: Text
What:ole
-----------------------------------------
Save as a single file, placed in a directory, open (must use http://...) ) getfile.htm
Uploading a. gif or. jpg can be displayed.
The loops and GetChunk methods may be used in the display program (showpic.asp) for large files. Do it yourself. Remember, because the ASP currently does not support the second to read and write, can only save binary to the database.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.