1.急急急!求ASP上传程序源码一个
急急急!求ASP上传程序源码一个
上传本身就是源码一个很难解决的问题,网上没有现成的源码植物源码教程可言。这有两个页面,源码仿下载页源码只能做到这一步了。源码hashmap源码分析以及重写你可以调用。源码php oa源码免费下载想自己学的源码idea源码对应不上话需要知道两个对象:dictionary和stream把属性和方法都搞清楚。还有一个ASP的源码对象的两个方法:Request.BinaryRead,Request.TotalBytes搞清楚
index.asp
'-----------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org//xhtml">
<head>
<meta content="text/html; charset=gb" http-equiv="Content-Type" />
<title>上传</title>
<style type="text/css">
body{ margin:0 auto 0;background:#6CF;}
#mainbox{ width:px;margin:0 auto 0;text-align:center;position:relative;}
h5{ margin:0;background:#FF0;color:#F}
form{ margin:0;}
ul{ list-style:none;margin:0;}
#showInfo{ position:absolute;height:px;background:#ff0;color:#F;width:px;bottom:0;left:0;}
</style>
</head>
<body>
<div id="mainbox">
<form action="accept.asp" enctype="multipart/form-data" method="post" name="theName">
<h5>上传</h5>
<ul>
<li><input name="pic" type="file" /></li>
<li>
<input id="Submit1" type="submit" value="上传" /></li>
</ul>
</form>
</div>
</body>
</html>
accept.asp
'-------------------------
<%
dim Data_Netout
Class Netout
dim objForm,objFile,Version
rem tStream为stream对象,FileInfo为类,源码sInfo
Private Sub Class_Initialize
dim RequestData,sStart,vbCrlf,sInfo,iInfoStart,iInfoEnd,tStream,iStart,theFile
dim iFileSize,sFilePath,sFileType,sFormValue,sFileName
dim iFindStart,iFindEnd
dim iFormStart,iFormEnd,sFormName
set objForm=Server.CreateObject("Scripting.Dictionary")
set objFile=Server.CreateObject("Scripting.Dictionary")
if Request.TotalBytes<1 then Exit Sub
set tStream = Server.CreateObject("adodb.stream")
set Data_Netout = Server.CreateObject("adodb.stream")
Data_Netout.Type = 1
Data_Netout.Mode =3
Data_Netout.Open
Data_Netout.Write Request.BinaryRead(Request.TotalBytes)
Data_Netout.Position=0
RequestData =Data_Netout.Read
iFormStart = 1
iFormEnd = LenB(RequestData)
vbCrlf = chrB() & chrB()
sStart = MidB(RequestData,1, InStrB(iFormStart,RequestData,vbCrlf)-1)
iStart = LenB (sStart)
iFormStart=iFormStart+iStart+1
while (iFormStart + ) < iFormEnd
iInfoEnd = InStrB(iFormStart,RequestData,vbCrlf & vbCrlf)+3
tStream.Type = 1
tStream.Mode =3
tStream.Open
Data_Netout.Position = iFormStart
Data_Netout.CopyTo tStream,iInfoEnd-iFormStart
tStream.Position = 0
tStream.Type = 2
tStream.Charset ="gb"
sInfo = tStream.ReadText
tStream.Close
'取得表单项目名称
iFormStart = InStrB(iInfoEnd,RequestData,sStart)
iFindStart = InStr(,sInfo,"name=""",1)+6
iFindEnd = InStr(iFindStart,sInfo,"""",1)
sFormName = lcase(Mid (sinfo,iFindStart,iFindEnd-iFindStart))
'如果是文件
if InStr (,sInfo,"filename=""",1) > 0 then
'取得文件信息
set theFile=new FileInfo
iFindStart = InStr(iFindEnd,sInfo,"filename=""",1)+
iFindEnd = InStr(iFindStart,sInfo,"""",1)
sFileName = Mid (sinfo,iFindStart,iFindEnd-iFindStart)
'取得文件名
theFile.FileName=getFileName(sFileName)
'取得文件路径
theFile.FilePath=getFilePath(sFileName)
'取得文件类型
iFindStart = InStr(iFindEnd,sInfo,"Content-Type: ",1)+
iFindEnd = InStr(iFindStart,sInfo,vbCr)
theFile.FileStart =iInfoEnd
'取得文件大小
theFile.FileSize = iFormStart -iInfoEnd -3
theFile.FormName=sFormName
if not objFile.Exists(sFormName) then
objFile.add sFormName,theFile
end if
else
'如果是表单项目
tStream.Type =1
tStream.Mode =3
tStream.Open
Data_Netout.Position = iInfoEnd
Data_Netout.CopyTo tStream,iFormStart-iInfoEnd-3
tStream.Position = 0
tStream.Type = 2
tStream.Charset ="gb"
sFormValue = tStream.ReadText
tStream.Close
if objForm.Exists(sFormName) then
objForm(sFormName)=objForm(sFormName)&", "&sFormValue
else
objForm.Add sFormName,sFormValue
end if
end if
iFormStart=iFormStart+iStart+1
wend
RequestData=""
set tStream =nothing
End Sub
Private Sub Class_Terminate
if Request.TotalBytes>0 then
objForm.RemoveAll
objFile.RemoveAll
set objForm=nothing
set objFile=nothing
Data_Netout.Close
set Data_Netout =nothing
end if
End Sub
Public function Form(strForm)
strForm=lcase(strForm)
if not objForm.exists(strForm) then
Form=""
else
Form=objForm(strForm)
end if
end function
Public function File(strFile)
strFile=lcase(strFile)
if not objFile.exists(strFile) then
set File=new FileInfo
else
set File=objFile(strFile)
end if
end function
Private function GetFilePath(FullPath)
If FullPath <> "" Then
GetFilePath = left(FullPath,InStrRev(FullPath, "\"))
Else
GetFilePath = ""
End If
End function
Private function GetFileName(FullPath)
If FullPath <> "" Then
GetFileName = mid(FullPath,InStrRev(FullPath, "\")+1)
Else
GetFileName = ""
End If
End function
End Class
Class FileInfo
dim FormName,FileName,FilePath,FileSize,FileStart
Private Sub Class_Initialize
FileName = ""
FilePath = ""
FileSize = 0
FileStart= 0
FormName = ""
End Sub
Public function SaveAs(FullPath)
dim dr,ErrorChar,i
SaveAs=true
if trim(fullpath)="" or FileStart=0 or FileName="" or right(fullpath,1)="/" then exit function
set dr=CreateObject("Adodb.Stream")
dr.Mode=3
dr.Type=1
dr.Open
Data_Netout.position=FileStart
Data_Netout.copyto dr,FileSize
dr.SaveToFile FullPath,2
dr.Close
set dr=nothing
SaveAs=false
end function
End Class
dim UpImages,File,formName,formPath,iCount
dim gFilePath,gPath,gRootUrl
dim ImageInfo(6),Content(6),FilePath(6)
set UpImages=new Netout ''建立上传对象
formPath="../images/"
for each formName in UpImages.objFile ''列出所有上传了的文件
set File=UpImages.file(formName) ''生成一个文件对象
if File.FileSize>0 and instr("jpg,gif,bmp,png",Lcase(right(File.FileName,3)))>0 then ''如果 FileSize > 0 说明有文件数据
randomize
ranNum=int(*rnd)+
FileName=formPath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&right(File.FileName,3)
File.SaveAs Server.mappath(FileName) ''保存文件
iCount=iCount+1
filesizecount=filesizecount+File.FileSize
end if
set File=nothing
next
%>