复制代码 代码如下:
<%
'--Loader.asp--
'--version1.5.2
'--lastupdated12/5/2002
'
'FaisalKhan
'faisal@stardeveloper.com
'www.stardeveloper.com
'Classforhandlingbinaryuploads
ClassLoader
Privatedict
PrivateSubClass_Initialize
Setdict=Server.CreateObject("Scripting.Dictionary")
EndSub
PrivateSubClass_Terminate
IfIsObject(intDict)Then
intDict.RemoveAll
SetintDict=Nothing
EndIf
IfIsObject(dict)Then
dict.RemoveAll
Setdict=Nothing
EndIf
EndSub
PublicPropertyGetCount
Count=dict.Count
EndProperty
PublicSubInitialize
IfRequest.TotalBytes>0Then
DimbinData
binData=Request.BinaryRead(Request.TotalBytes)
getDatabinData
EndIf
EndSub
PublicFunctiongetFileData(name)
Ifdict.Exists(name)Then
getFileData=dict(name).Item("Value")
Else
getFileData=""
EndIf
EndFunction
PublicFunctiongetValue(name)
Dimgv
Ifdict.Exists(name)Then
gv=CStr(dict(name).Item("Value"))
gv=Left(gv,Len(gv)-2)
getValue=gv
Else
getValue=""
EndIf
EndFunction
PublicFunctionsaveToFile(name,path)
Ifdict.Exists(name)Then
Dimtemp
temp=dict(name).Item("Value")
Dimfso
Setfso=Server.CreateObject("Scripting.FileSystemObject")
Dimfile
Setfile=fso.CreateTextFile(path)
FortPoint=1toLenB(temp)
file.WriteChr(AscB(MidB(temp,tPoint,1)))
Next
file.Close
saveToFile=True
Else
saveToFile=False
EndIf
EndFunction
PublicFunctiongetFileName(name)
Ifdict.Exists(name)Then
Dimtemp,tempPos
temp=dict(name).Item("FileName")
tempPos=1+InStrRev(temp,"")
getFileName=Mid(temp,tempPos)
Else
getFileName=""
EndIf
EndFunction
PublicFunctiongetFilePath(name)
Ifdict.Exists(name)Then
Dimtemp,tempPos
temp=dict(name).Item("FileName")
tempPos=InStrRev(temp,"")
getFilePath=Mid(temp,1,tempPos)
Else
getFilePath=""
EndIf
EndFunction
PublicFunctiongetFilePathComplete(name)
Ifdict.Exists(name)Then
getFilePathComplete=dict(name).Item("FileName")
Else
getFilePathComplete=""
EndIf
EndFunction
PublicFunctiongetFileSize(name)
Ifdict.Exists(name)Then
getFileSize=LenB(dict(name).Item("Value"))
Else
getFileSize=0
EndIf
EndFunction
PublicFunctiongetFileSizeTranslated(name)
Ifdict.Exists(name)Then
temp=LenB(dict(name).Item("Value"))
Iftemp<=1024Then
getFileSizeTranslated=temp&"bytes"
Else
temp=FormatNumber((temp/1024),2)
getFileSizeTranslated=temp&"kilobytes"
EndIf
Else
getFileSizeTranslated=""
EndIf
EndFunction
PublicFunctiongetContentType(name)
Ifdict.Exists(name)Then
getContentType=dict(name).Item("ContentType")
Else
getContentType=""
EndIf
EndFunction
PrivateSubgetData(rawData)
Dimseparator
separator=MidB(rawData,1,InstrB(1,rawData,ChrB(13))-1)
DimlenSeparator
lenSeparator=LenB(separator)
DimcurrentPos
currentPos=1
DiminStrByte
inStrByte=1
Dimvalue,mValue
DimtempValue
tempValue=""
WhileinStrByte>0
inStrByte=InStrB(currentPos,rawData,separator)
mValue=inStrByte-currentPos
IfmValue>1Then
value=MidB(rawData,currentPos,mValue)
DimbegPos,endPos,midValue,nValue
DimintDict
SetintDict=Server.CreateObject("Scripting.Dictionary")
begPos=1+InStrB(1,value,ChrB(34))
endPos=InStrB(begPos+1,value,ChrB(34))
nValue=endPos
DimnameN
nameN=MidB(value,begPos,endPos-begPos)
DimnameValue,isValid
isValid=True
IfInStrB(1,value,stringToByte("Content-Type"))>1Then
begPos=1+InStrB(endPos+1,value,ChrB(34))
endPos=InStrB(begPos+1,value,ChrB(34))
IfendPos=0Then
endPos=begPos+1
isValid=False
EndIf
midValue=MidB(value,begPos,endPos-begPos)
intDict.Add"FileName",trim(byteToString(midValue))
begPos=14+InStrB(endPos+1,value,stringToByte("Content-Type:"))
endPos=InStrB(begPos,value,ChrB(13))
midValue=MidB(value,begPos,endPos-begPos)
intDict.Add"ContentType",trim(byteToString(midValue))
begPos=endPos+4
endPos=LenB(value)
nameValue=MidB(value,begPos,((endPos-begPos)-1))
Else
nameValue=trim(byteToString(MidB(value,nValue+5)))
EndIf
IfisValid=TrueThen
intDict.Add"Value",nameValue
intDict.Add"Name",nameN
dict.AddbyteToString(nameN),intDict
EndIf
EndIf
currentPos=lenSeparator+inStrByte
Wend
EndSub
EndClass
PrivateFunctionstringToByte(toConv)
DimtempChar
Fori=1toLen(toConv)
tempChar=Mid(toConv,i,1)
stringToByte=stringToByte&chrB(AscB(tempChar))
Next
EndFunction
PrivateFunctionbyteToString(toConv)
Fori=1toLenB(toConv)
byteToString=byteToString&Chr(AscB(MidB(toConv,i,1)))
Next
EndFunction
%>
1、用户界面:
复制代码 代码如下:
<scriptlanguage="JavaScript">
functionCheckAll(form)
{for(vari=0;i<form.elements.length;i++)
{vare=form.elements[i];
if(e.name!='chkall')
e.checked=form.chkall.checked;
}
}
</script>
</head>
<body>
<formmethod="post"action="del.asp"name="form1">
<table>
<tr>
<td><inputtype="checkbox"value="111"name="TradeName">电子邮件1</td>
</tr>
<tr>
<td><inputtype="checkbox"value="111"name="TradeName">电子邮件2</td>
</tr>
<tr>
<td><inputtype="checkbox"value="111"name="TradeName">电子邮件3</td>
</tr>
<tr>
<td><inputtype="checkbox"value="111"name="TradeName">电子邮件4</td>
</tr>
<tr>
<td><inputtype="checkbox"value="111"name="TradeName">电子邮件5</td>
</tr>
<tr>
<td><inputtype="checkbox"value="111"name="TradeName">电子邮件6</td>
</tr>
<tr>
<tdbgcolor="#F1FBFC"height="25"colspan="2">
<palign="left"><inputtype="checkbox"name="chkall"value="on"onclick="CheckAll(this.form)"><fontcolor="#FF9900">选中所有显示的消息</font></p>
</td>
<center>
</tr>
</table>
</form>
2、删除文件del.asp
<%
'这行写连接数据库的代码
dimID,strID
strID=""
ForEachstrIDInRequest.Form("TradeName")
ID=Cint(strID)
ifstrID<>""then
DelRs=Server.CreateObject("ADODB.Recordset")
Conn.Execute"DeleteFromTbnamewhereID="&Cstr(ID)
strID=""
endif
Next
Conn.Close
SetConn=Nothing
Response.Redirect"成功删除!"
%>
【[ASP]精华代码】相关文章:
★ ASP的天空小偷