Essence | Problem Case table Test
ID int IDENTITY (1, 1) not NULL;
Testtext ntext;
Images image;
The forms in the submission file are set as follows:
<form method= "POST" action= "upload.asp" Name= "Form1" enctype= "Multipart/form-data" target= "_blank" >
Figure: <input type= "file" Name= "File1" ></form>
<form method= "POST" action= "textprocess.asp" onsubmit= "return Validate (this);" Name= "Form2" >
<input type= "text" name= "Testtext" >
</form>
Also add the following code to the head of the file that submits the form:
<script language= "JavaScript" >
function Validate (Form2)
{
Form1.submit ();
}
</script>
The main code in upload.asp:
<!--#include file= "connectdb.asp"--><%
Formsize = Request.TotalBytes ' Get data
FormData = Request.BinaryRead (formsize)
function Imageup (formsize,formdata) ' functions are to intercept the part of the image.
BNCRLF=CHRB & ChrB (10) ' After the function is made. You can use it at your own discretion later.
Divider=leftb (FORMDATA,INSTRB (FORMDATA,BNCRLF)-1)
DATASTART=INSTRB (FORMDATA,BNCRLF&BNCRLF) +4
DATAEND=INSTRB (Datastart+1,formdata,divider)-datastart
IMAGEUP=MIDB (Formdata,datastart,dataend)
End Function
Image=imageup (Formsize,formdata) ' This is the image part.
If formsize<> "" Then
Response.Write "Uploading Your signature picture ....<br>"
Set Rs=server. CreateObject ("Adodb.recordset")
Sql= "SELECT * from test where ID is null"
Rs. Open sql,conn,1,3
Rs. AddNew ' because form two was submitted in the process of single submission of the form.
RS ("Images"). AppendChunk Image ' So here is added.
Rs. Update
Rs. Close
Set rs=nothing
Conn.close
Set conn=nothing
Response.Write "Signature picture upload end!<br>"
End If%>
Textprocess.asp Main code:
<!--#include file= "connectdb.asp"-->
<%
Set Rs2=server. CreateObject ("Adodb.recordset")
Rs2.open "SELECT top 1 * FROM Test ORDER BY id DESC", conn,1,3
RS2 ("Testtext") =request ("Testtext")
Rs2.update
Rs2.close
Set rs2=nothing%>
Here is the code to display the picture showimg.asp
<!--#include file= "connectdb.asp"-->
<%
Response.expires=0
Response.buffer=true
Response.Clear
Response.ContentType = "image/*"
Set Rs=createobject ("Adodb.recordset")
Sql= "SELECT * from Test where id=" & Request.QueryString ("id")
Rs.Open sql,conn,1,1
Response.BinaryWrite rs ("signature")
Rs.close
Set rs=nothing
Conn.close
Set conn=nothing%>
OK, the place to show the picture as long as write on it, this I tested under WIN2K,SQL2K, no problem