The best example of a pure ASP uploading image files to a database

Source: Internet
Author: User
Iamtrue published in 2000-11-2 7:56:49 ASP zone
Getfile.htm
-------------------------
<title> save pictures to database </title>
<body>
<b>
<p></b> you can find a picture to try, after saving will be prompted </p>
<form method= "POST" enctype= "Multipart/form-data" action= "savetodb.asp" >
<p>email: <input name= "Email" value= "wangcq@sina.com" size= "><br>"
Picture: <input type= "file" Name= "blob" ><br>
<input type= "Submit" Name= "Enter" > </p>
</form>
</body>
Savetodb.asp
----------------------------------
<%
Response.Buffer = TRUE
Response.Clear
ByteCount = Request.TotalBytes
Requestbin = Request.BinaryRead (ByteCount)
Dim Uploadrequest
Set uploadrequest = CreateObject ("Scripting.Dictionary")
Builduploadrequest Requestbin
email = uploadrequest.item ("email"). Item ("Value")
ContentType = Uploadrequest.item ("blob"). Item ("ContentType")
Filepathname = Uploadrequest.item ("blob"). Item ("FileName")
filename = right (Filepathname,len (filepathname)-instrrev (Filepathname, "")
Picture = Uploadrequest.item ("blob"). Item ("Value")
' Response.ContentType = ContentType
' Response.BinaryWrite picture
Set objCN = Server.CreateObject ("Adodb.connection")
Set Objrst = Server.CreateObject ("Adodb.recordset")
Objcn.open "Upload"
Objrst. Open "Pic", OBJCN, 1,3,2
Objrst.addnew
Objrst.fields ("filename") =filename
Objrst.fields ("type") = "gif"
Objrst.fields ("what"). AppendChunk picture
Objrst.update
Response.Write "<a href=showpic.asp?id=" & Objrst ("id") & "> First" & Objrst ("id") & "picture. </a> "

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.