Allows you to easily upload images to a database.
I want to write it myself for a long timeProgramBut I don't want to write it to me. Today is just free, so it's easy to get started with this small program:
Let's make an upload. The field ID of the data database is automatically numbered. The big field type is Ole.
Uppic. asp upload program name
<%
Dim rs
Dim formsize, formdata, bncrlf, divider, datastart, dataend, mydata
Formsize = request. totalbytes 'Get the size sent from the client
Formdata = request. binaryread (formsize) 'converts the data sent by the customer into binary
Bncrlf = chrb (13) & chrb (10)
Divider = leftb (formdata, clng (partition B (formdata, bncrlf)-1)
Datastart = instrb (formdata, bncrlf & bncrlf) + 4
Dataend = Consumer B (datastart + 1, formdata, divider)-datastart
Mydata = midb (formdata, datastart, dataend) 'above is a total of binary data obtained from the image
%>
<! -- # Include file = "conn. asp" -->
<%
SQL = "select * from PIC order by ID DESC"
Set rs = server. Createobject ("ADODB. recordset ")
Rs. Open SQL, Conn, 3, 2
Rs. addnew
RS ("big"). AppendChunk mydata is added to the database.
Rs. Update
Set rs = nothing
Set conn = nothing
%>
Next, display the image.
Display. asp
<! -- # Include file = "conn. asp" --> 'Everyone knows that he is a program connected to the database.
<%
Id = request ("ID ")
Set rs = server. Createobject ("ADODB. recordset ")
SQL = "select * from PIC where id =" & ID
Rs. Open SQL, Conn, 1, 1
Response. contenttype = "text/html" 'the format of the displayed image can also be used
'Response. contenttype = "image/GIF" displayed as GIF
'Response. contenttype = "image/jpg" displayed as JPG
Response. binarywrite RS ("big") 'show image
Rs. Close
Set rs = nothing
Set conngraph = nothing
%>