ASP file upload function library

Source: Internet
Author: User
Tags chr file upload
54 powerman
Note:
If you need the string value of the file form, use GetFullName ("file ")
If you need a file Form file name, use GetFileName ("file ")
If you need the file Form Extension, use GetExtName ("file ")
If you need the value of a common text form, use MyRequest ("password ")
If the binary value of the file form is required, MyRequest ("file") is also used ")
Save the file with SaveFile ("file", "myUpload.jpg ")
Format of writing data to the database:
Rs. AppandChunk MyRequest ("file ")
<%
'Program: 54 powerman
'Email & MSN: 54powerman@163.com
'Qq: 19486554
'Initialize data
Response. buffer = true
FormData = Request. BinaryRead (Request. TotalBytes)
Bncrlf = ChrB (13) & ChrB (10)
Set sr = CreateObject ("Adodb. Stream ")
Sr. Mode = 3
Sr. Type = 1
Sr. Open
Sr. Write FormData
Init = sr
'Common functions
Function Str2B (Str)
For I = 1 To len (Str)
Str2B = Str2B & ChrB (Asc (Mid (Str, I, 1 )))
Next
End Function
Function B2Str (Str)
For I = 1 To LenB (Str)
ThisCharCode = AscB (MidB (Str, I, 1 ))
If ThisCharCode <& H80 Then
B2Str = B2Str & Chr (ThisCharCode)
Else
NextCharCode = AscB (MidB (Str, I + 1, 1 ))
B2Str = B2Str & Chr (CLng (ThisCharCode) * & H100 + CInt (NextCharCode ))
I = I + 1
End If
Next
End Function
Function MyRequest (FormName)
Divider = leftb (FormData, role B (FormData, bncrlf)-1)
Cur = capacity B (FormData, Str2B ("name =") & ChrB (34) & Str2B (FormName) & ChrB (34 ))
MyRequest = null
DataStart = capacity B (Cur, FormData, bncrlf & bncrlf) + 4
DataEnd = Consumer B (DataStart + 1, FormData, divider)-DataStart
TempStr = Midb (FormData, Cur, DataStart)
If Then B (TempStr, Str2B ("filename =") Then
MyRequest = Midb (FormData, DataStart, DataEnd)
Else
Related Article

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.