Picture data stored in the database:
Sqlstr= ' select * from ' &tbname& ' where ID is null '
Set Rs=server.createobject ("Adodb.recordset")
Rs. Open sqlstr,conn,1,3
Rs. AddNew ()
RS ("title") =title
RS ("filename") =filename
RS ("filetype") =filetype
RS ("Thelevel") =thelevel
RS ("Uploaddate") =date ()
RS ("Uploadip") =request. ServerVariables ("REMOTE_ADDR")
RS ("contenttype") =contenttype
RS ("Data"). AppendChunk (BINSTR)
RS ("size") =size
RS ("offset") =offset
Rs. Update
Rs. Close ()
Read display:
Rs. Open sqlstr,conn,3
If not Rs. EOF Then
Contenttype=rs ("contenttype")
Binstr=rs ("Data"). GetChunk (RS ("size") +rs ("offset")
If RS ("offset") =1 Then
BINSTR=MIDB (binstr,2)
End If
If InStr (ContentType, "text/") =1 or _
InStr (ContentType, "image/") =1 or _
InStr (ContentType, "Application/msword") =1 Then
Response.contenttype=trim (ContentType)
Response.BinaryWrite Binstr
Else
Response.AddHeader "Content-disposition", "Attachment;filename=" "" "&rs (" filename ") &" ""
Response.contenttype=trim (ContentType)
Response.BinaryWrite Binstr
End If
If Request ("preview") <> "yes" then
sqlstr= "Update" &tbname& "set downtimes=downtimes+1 where id=" &fileid
Conn. Execute Sqlstr
End If
End If
Description
Use fieldname for very long binary data, such as image data. AppendChunk () and FieldName. GetChunk () to read and write.
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