ASP文件上传函数库
54powerman说明:
如果你需要file表单的串值,用GetFullName("file")
如果需要file表单的文件名,用GetFileName("file")
如果需要file表单的扩展名,用GetExtName("file")
如果需要普通文本表单的值,用MyRequest("password")
如果需要file表单的二进制值,也是用MyRequest("file")
保存文件用SaveFile("file","myUpload.jpg")
写入数据库的格式:
Rs.AppandChunk MyRequest("file")
<%
'Program:54powerman
'EMail & MSN:54powerman@163.com
'QQ:19486554
'初始化数据
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
'常用函数
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,inStrb(FormData,bncrlf)-1)
Cur = inStrb(FormData,Str2B("name=")&ChrB(34)&Str2B(FormName)&ChrB(34))
MyRequest=null
DataStart=inStrb(Cur,FormData,bncrlf&bncrlf)+4
DataEnd = inStrb(DataStart+1,FormData,divider)-DataStart
TempStr = Midb(FormData,Cur,DataStart)
If inStrb(TempStr,Str2B("filename=")) Then
MyRequest = Midb(FormData,DataStart,DataEnd)
else
补充:asp教程,高级应用