导航:首页 > 编程语言 > asp无组件上传代码下载

asp无组件上传代码下载

发布时间:2025-06-15 23:32:41

① 求asp无组件上传图片代码 100分悬赏

ASP无组件上传图片源代码
<%
'上传方法,0=无组件,1=chinaaspupload
dim upload_type
upload_type=upload

dim uploadsuc
dim Forumupload
dim ranNum
dim uploadfiletype
dim upload,file,formName,formPath,iCount,filename,fileExt
response.write "<body leftmargin=0 topmargin=0>"
select case upload_type
case 0
call upload_0()
case 1
call upload_1()
case else
response.write "本系统未开放插件功能"
response.end
end select

sub upload_0()
set upload=new upload_5xSoft ''建立上传对象

formPath=upload.form("filepath")
''在目录后加(/)
if right(formPath,1)<>"/" then formPath=formPath&"/"

response.write "<body leftmargin=5 topmargin=3>"

for each formName in upload.file ''列出所有上传了的文件
set file=upload.file(formName) ''生成一个文件对象
if file.filesize<100 then
response.write "<span style=""font-family: 宋体; font-size: 9pt"">请先选择你要上传的图片 [ <a href=# onclick=history.go(-1)>重新上传</a> ]</span>"
response.end
end if

if file.filesize>1024000 then
response.write "<span style=""font-family: 宋体; font-size: 9pt"">图片大小超过了限制 [ <a href=# onclick=history.go(-1)>重新上传</a> ]</span>"
response.end
end if

fileExt=lcase(getFileExtName(file.fileName))

if fileext<>"jpg" and fileext<>"png" and fileext<>"gif" and fileext<>"bmp" then
response.write "<span style=""font-family: 宋体; font-size: 9pt"">该文件格式不允许上传 [ <a href=# onclick=history.go(-1)>重新上传</a> ]</span>"
response.end
end if

randomize
rannum=int(90000*rnd)+10000
filename=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&rannum&"."&fileExt
%>
<%
if file.FileSize>0 then ''如果 FileSize > 0 说明有文件数据
file.SaveAs Server.mappath(formPath &filename) ''保存文件
response.write "<script>parent.document.FrmAddLink.photo.value='uploadfile/face/"&FileName&"'</script>"
end if
set file=nothing
next
set upload=nothing

Htmend iCount&" 个文件上传结束!"
end sub

sub HtmEnd(Msg)
response.write "<span style=""font-family: 宋体; font-size: 9pt"">图片上传成功 [ <a href=# onclick=history.go(-1)>重新上传</a> ]</span>"

response.end
end sub

sub upload_1()
set FileUp=server.createobject("ChinaASP.UpLoad") ''建立上传对象

filepath=server.MapPath("../uploadfile/face/")

response.write "<body leftmargin=5 topmargin=3>"
for each f in fileup.Files ''列出所有上传了的文件

if f.filesize<100 then
response.write "<span style=""font-family: 宋体; font-size: 9pt"">请先选择你要上传的图片 [ <a href=# onclick=history.go(-1)>重新上传</a> ]</span>"
response.end
end if

if f.filesize>1024000 then
response.write "<span style=""font-family: 宋体; font-size: 9pt"">图片大小超过了限制 [ <a href=# onclick=history.go(-1)>重新上传</a> ]</span>"
response.end
end if

fileExt=lcase(getFileExtName(f.fileName))

if fileext<>"jpg" and fileext<>"png" and fileext<>"gif" and fileext<>"bmp" then
response.write "<span style=""font-family: 宋体; font-size: 9pt"">该文件格式不允许上传 [ <a href=# onclick=history.go(-1)>重新上传</a> ]</span>"
response.end
end if

randomize
rannum=int(90000*rnd)+10000
filename=formPath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&rannum&"."&fileExt
%>
<%
if f.FileSize>0 then ''如果 FileSize > 0 说明有文件数据
f.saveas filePath & "\"&filename ''保存文件
response.write "<script>parent.document.FrmAddLink.photo.value='uploadfile/face/"&FileName&"'</script>"
end if
set f=nothing
next
set FileUp=nothing

Htmend iCount&" 个文件上传结束!"
end sub

sub HtmEnd(Msg)
response.write "<span style=""font-family: 宋体; font-size: 9pt"">图片上传成功 [ <a href=# onclick=history.go(-1)>重新上传</a> ]</span>"

response.end
end sub
%>

② 高分求ASP上传文件代码

不多说了,我把源码传上网了,你可以打开 http://tonv.b67.53dns.cn 传文件看看是不是你要的效果。 http://tonv.b67.53dns.cn/view.asp 是文件显示页面,我已经把源码打包传上去了,编号16的就是,直接点“点击打开”就可以下载

补充:第一个提交是上传文件的提交,此时提交后文件会被成功上传且把路径和文件名写入到<input name="content">这个文本域内,也就是你提交到数据库的字段
第二个提交是提交index.asp表单的,也就是你自己要提交到数据库里的表单。简而言之只要你将代码弄好了,这个提交就会保存文件名到数据库,存入数据库后要显示文件名和路径就可以调用<%=rs("content")>,content是你数据库存放上传文件名和路径的字段名!你再试试,不会我发完整源码给你,你如果想上传的时候同时提交到数据库可以在upload.asp页面用个隐藏表单。

另外第一个文本域是我测试的时候上传到数据库的另外一个字段title,可以不用管,关键部分在第二个文本域,是取得上传文件名和路径的字段

****************************************************************

嘿,都是骗分的嚒,看清楚了楼主要显示上传文件名并写入数据库,没问题,看我的: (有四个asp文件,别把代码复制到一个页面中了,有什么问题请补充!如果还不会请告诉我,我把源码打包发给你!)

UpLoadClass.asp,主要上传程序,代码如下:
<%
Class UpLoadClass

Private p_MaxSize,p_TotalSize,p_FileType,p_SavePath,p_AutoSave,p_Error
Private objForm,binForm,binItem,strDate,lngTime
Public FormItem,FileItem

Public Property Get Version
Version="Rumor UpLoadClass Version 2.0B"
End Property

Public Property Get Error
Error=p_Error
End Property

Public Property Get MaxSize
MaxSize=p_MaxSize
End Property
Public Property Let MaxSize(lngSize)
if isNumeric(lngSize) then
p_MaxSize=clng(lngSize)
end if
End Property

Public Property Get TotalSize
TotalSize=p_TotalSize
End Property
Public Property Let TotalSize(lngSize)
if isNumeric(lngSize) then
p_TotalSize=clng(lngSize)
end if
End Property

Public Property Get FileType
FileType=p_FileType
End Property
Public Property Let FileType(strType)
p_FileType=strType
End Property

Public Property Get SavePath
SavePath=p_SavePath
End Property
Public Property Let SavePath(strPath)
p_SavePath=replace(strPath,chr(0),"")
End Property

Public Property Get AutoSave
AutoSave=p_AutoSave
End Property
Public Property Let AutoSave(byVal Flag)
select case Flag
case 0:
case 1:
case 2:
case false:Flag=2
case else:Flag=0
end select
p_AutoSave=Flag
End Property

Private Sub Class_Initialize
p_Error = -1
p_MaxSize = 153600
p_FileType = "jpg/gif"
p_SavePath = ""
p_AutoSave = 0
p_TotalSize= 0
strDate = replace(cstr(Date()),"-","")
lngTime = clng(timer()*1000)
Set binForm = Server.CreateObject("ADODB.Stream")
Set binItem = Server.CreateObject("ADODB.Stream")
Set objForm = Server.CreateObject("Scripting.Dictionary")
objForm.CompareMode = 1
End Sub

Private Sub Class_Terminate
objForm.RemoveAll
Set objForm = nothing
Set binItem = nothing
if p_Error<>4 then binForm.Close()
Set binForm = nothing
End Sub

Public Sub Open()
if p_Error=-1 then
p_Error=0
else
Exit Sub
end if
Dim lngRequestSize,binRequestData,strFormItem,strFileItem
Const strSplit="'"">"
lngRequestSize=Request.TotalBytes
if lngRequestSize<1 or (lngRequestSize>p_TotalSize and p_TotalSize<>0) then
p_Error=4
Exit Sub
end if
binRequestData=Request.BinaryRead(lngRequestSize)
binForm.Type = 1
binForm.Open
binForm.Write binRequestData

Dim bCrLf,strSeparator,intSeparator
bCrLf=ChrB(13)&ChrB(10)

intSeparator=InstrB(1,binRequestData,bCrLf)-1
strSeparator=LeftB(binRequestData,intSeparator)

Dim p_start,p_end,strItem,strInam,intTemp,strTemp
Dim strFtyp,strFnam,strFext,lngFsiz
p_start=intSeparator+2
Do
p_end =InStrB(p_start,binRequestData,bCrLf&bCrLf)+3
binItem.Type=1
binItem.Open
binForm.Position=p_start
binForm.CopyTo binItem,p_end-p_start
binItem.Position=0
binItem.Type=2
binItem.Charset="gb2312"
strItem=binItem.ReadText
binItem.Close()

p_start=p_end
p_end =InStrB(p_start,binRequestData,strSeparator)-1
binItem.Type=1
binItem.Open
binForm.Position=p_start
lngFsiz=p_end-p_start-2
binForm.CopyTo binItem,lngFsiz

intTemp=Instr(39,strItem,"""")
strInam=Mid(strItem,39,intTemp-39)

if Instr(intTemp,strItem,"filename=""")<>0 then
if not objForm.Exists(strInam&"_From") then
strFileItem=strFileItem&strSplit&strInam
if binItem.Size<>0 then
intTemp=intTemp+13
strFtyp=Mid(strItem,Instr(intTemp,strItem,"Content-Type: ")+14)
strTemp=Mid(strItem,intTemp,Instr(intTemp,strItem,"""")-intTemp)
intTemp=InstrRev(strTemp,"\")
strFnam=Mid(strTemp,intTemp+1)
objForm.Add strInam&"_Type",strFtyp
objForm.Add strInam&"_Name",strFnam
objForm.Add strInam&"_Path",Left(strTemp,intTemp)
objForm.Add strInam&"_Size",lngFsiz
if Instr(intTemp,strTemp,".")<>0 then
strFext=Mid(strTemp,InstrRev(strTemp,".")+1)
else
strFext=""
end if
if left(strFtyp,6)="image/" then
binItem.Position=0
binItem.Type=1
strTemp=binItem.read(10)
if strcomp(strTemp,chrb(255) & chrb(216) & chrb(255) & chrb(224) & chrb(0) & chrb(16) & chrb(74) & chrb(70) & chrb(73) & chrb(70),0)=0 then
if Lcase(strFext)<>"jpg" then strFext="jpg"
binItem.Position=3
do while not binItem.EOS
do
intTemp = ascb(binItem.Read(1))
loop while intTemp = 255 and not binItem.EOS
if intTemp < 192 or intTemp > 195 then
binItem.read(Bin2Val(binItem.Read(2))-2)
else
Exit do
end if
do
intTemp = ascb(binItem.Read(1))
loop while intTemp < 255 and not binItem.EOS
loop
binItem.Read(3)
objForm.Add strInam&"_Height",Bin2Val(binItem.Read(2))
objForm.Add strInam&"_Width",Bin2Val(binItem.Read(2))
elseif strcomp(leftB(strTemp,8),chrb(137) & chrb(80) & chrb(78) & chrb(71) & chrb(13) & chrb(10) & chrb(26) & chrb(10),0)=0 then
if Lcase(strFext)<>"png" then strFext="png"
binItem.Position=18
objForm.Add strInam&"_Width",Bin2Val(binItem.Read(2))
binItem.Read(2)
objForm.Add strInam&"_Height",Bin2Val(binItem.Read(2))
elseif strcomp(leftB(strTemp,6),chrb(71) & chrb(73) & chrb(70) & chrb(56) & chrb(57) & chrb(97),0)=0 or strcomp(leftB(strTemp,6),chrb(71) & chrb(73) & chrb(70) & chrb(56) & chrb(55) & chrb(97),0)=0 then
if Lcase(strFext)<>"gif" then strFext="gif"
binItem.Position=6
objForm.Add strInam&"_Width",BinVal2(binItem.Read(2))
objForm.Add strInam&"_Height",BinVal2(binItem.Read(2))
elseif strcomp(leftB(strTemp,2),chrb(66) & chrb(77),0)=0 then
if Lcase(strFext)<>"bmp" then strFext="bmp"
binItem.Position=18
objForm.Add strInam&"_Width",BinVal2(binItem.Read(4))
objForm.Add strInam&"_Height",BinVal2(binItem.Read(4))
end if
end if
objForm.Add strInam&"_Ext",strFext
objForm.Add strInam&"_From",p_start
intTemp=GetFerr(lngFsiz,strFext)
if p_AutoSave<>2 then
objForm.Add strInam&"_Err",intTemp
if intTemp=0 then
if p_AutoSave=0 then
strFnam=GetTimeStr()
if strFext<>"" then strFnam=strFnam&"."&strFext
end if
binItem.SaveToFile Server.MapPath(p_SavePath&strFnam),2
objForm.Add strInam,strFnam
end if
end if
else
objForm.Add strInam&"_Err",-1
end if
end if
else
binItem.Position=0
binItem.Type=2
binItem.Charset="gb2312"
strTemp=binItem.ReadText
if objForm.Exists(strInam) then
objForm(strInam) = objForm(strInam)&","&strTemp
else
strFormItem=strFormItem&strSplit&strInam
objForm.Add strInam,strTemp
end if
end if

binItem.Close()
p_start = p_end+intSeparator+2
loop Until p_start+3>lngRequestSize
FormItem=split(strFormItem,strSplit)
FileItem=split(strFileItem,strSplit)
End Sub

Private Function GetTimeStr()
lngTime=lngTime+1
GetTimeStr=strDate&lngTime
End Function

Private Function GetFerr(lngFsiz,strFext)
dim intFerr
intFerr=0
if lngFsiz>p_MaxSize and p_MaxSize>0 then
if p_Error=0 or p_Error=2 then p_Error=p_Error+1
intFerr=intFerr+1
end if
if Instr(1,LCase("/"&p_FileType&"/"),LCase("/"&strFext&"/"))=0 and p_FileType<>"" then
if p_Error<2 then p_Error=p_Error+2
intFerr=intFerr+2
end if
GetFerr=intFerr
End Function

Public Function Save(Item,strFnam)
Save=false
if objForm.Exists(Item&"_From") then
dim intFerr,strFext
strFext=objForm(Item&"_Ext")
intFerr=GetFerr(objForm(Item&"_Size"),strFext)
if objForm.Exists(Item&"_Err") then
if intFerr=0 then
objForm(Item&"_Err")=0
end if
else
objForm.Add Item&"_Err",intFerr
end if
if intFerr<>0 then Exit Function
if VarType(strFnam)=2 then
select case strFnam
case 0:strFnam=GetTimeStr()
if strFext<>"" then strFnam=strFnam&"."&strFext
case 1:strFnam=objForm(Item&"_Name")
end select
end if
binItem.Type = 1
binItem.Open
binForm.Position = objForm(Item&"_From")
binForm.CopyTo binItem,objForm(Item&"_Size")
binItem.SaveToFile Server.MapPath(p_SavePath&strFnam),2
binItem.Close()
if objForm.Exists(Item) then
objForm(Item)=strFnam
else
objForm.Add Item,strFnam
end if
Save=true
end if
End Function

Public Function GetData(Item)
GetData=""
if objForm.Exists(Item&"_From") then
if GetFerr(objForm(Item&"_Size"),objForm(Item&"_Ext"))<>0 then Exit Function
binForm.Position = objForm(Item&"_From")
GetData=binFormStream.Read(objForm(Item&"_Size"))
end if
End Function

Public Function Form(Item)
if objForm.Exists(Item) then
Form=objForm(Item)
else
Form=""
end if
End Function

Private Function BinVal2(bin)
dim lngValue,i
lngValue = 0
for i = lenb(bin) to 1 step -1
lngValue = lngValue *256 + ascb(midb(bin,i,1))
next
BinVal2=lngValue
End Function

Private Function Bin2Val(bin)
dim lngValue,i
lngValue = 0
for i = 1 to lenb(bin)
lngValue = lngValue *256 + ascb(midb(bin,i,1))
next
Bin2Val=lngValue
End Function

End Class
%>
****************************************************

upload.asp 上传设置与调用文件,代码如下:
<!--#include FILE="UpLoadClass.asp"-->
<%
dim request2,ming
'建立上传对象
set request2=New UpLoadClass
'上传总大小为20M
request2.TotalSize= 20971520
'单文件最大10M
request2.MaxSize = 10485760
'允许上传的文件格式
request2.FileType = "rar/zip/jpg"
'设置上传文件的目录,使用相对路径,注意设置的目录要存在,不然会出错,如果为设置为空则文件上传于根目录下
request2.SavePath="upload/"
request2.open()
'设置ming这个变量等于上传文件的路径和文件名
ming = request2.SavePath&request2.Form("strFile1")
'在提交数据库页面把文件路径和文件名写入表单以供提交
response.write "<script>parent.document.form1.content.value='" & ming & "'</script>"
%>
*************************************************
up.asp,上传提交表单页面,代码如下
<form action="upload.asp" method="post" enctype="multipart/form-data" name="form">
<input type="file" name="strFile1" id="strFile1">
<input type="submit" name="Submit" value="提交">
</form>
*************************************************
index.asp 你自己的提交页面,我只写表单部分的代码
<form name="form1" method="POST" action="">
<input name="title" type="text" id="title">
<br><br>
<input name="content" type="text" id="content">
<br><iframe src="up.asp" name="up" width="300" marginwidth="0" height="30" marginheight="0" align="middle" scrolling="no" frameborder="0"></iframe>
<input type="submit" name="Submit" value="上传">
<br>
<input type="hidden" name="MM_insert" value="form1">
</form>

OK,完工了,这里用的是风声无组件上传,根据你的需要修改成你要的版本,还可以多文件上传的,你可以下一个风声的源码研究看看

另外,程序的主要你要的部分就是upload.asp中的:response.write "<script>parent.document.form1.content.value='" & ming & "'</script>" 这个是把上传得到的文件名和路径写入你要提交的表单,还有你自己的页面要用<iframe>调用up.asp。还有什么不懂的可以QQ问我:54660142

③ 如何在asp中使用无组件上传文件!

2个文件
第一个文件:
<html>
<body>
<center>
<form name="mainForm" enctype="multipart/form-data" action="process.asp" method=post>
<input type=file name=mefile><br>
<input type=submit name=okvalue="OK">
</form>
</center>
</body>
</html>

第二个:
<%
sub pic()
if Request.QueryString("submit")="pic" then
uploadpath="image/face/"
uploadsize="2048"
uploadtype="jpg/gif/png/bmp"
Set Uprequest=new UpLoadClass
Uprequest.SavePath=uploadpath
Uprequest.MaxSize=uploadsize*1024
Uprequest.FileType=uploadtype
AutoSave=true
Uprequest.open
if Uprequest.form("file_Err")<>0 then
select case Uprequest.form("file_Err")
case 1:str="<div style=""padding-top:5px;padding-bottom:5px;""> <font color=blue>上传不成功!文件超过"&uploadsize&"k [<a href='javascript:history.go(-1)'>重新上传</a>]</font></div>"
case 2:str="<div style=""padding-top:5px;padding-bottom:5px;""> <font color=blue>上传不成功!文件格式不对 [<a href='javascript:history.go(-1)']>重新上传</a>]</font></div>"
case 3:str="<div style=""padding-top:5px;padding-bottom:5px;""> <font color=blue>上传不成功!文件太大且格式不对 [<a href='javascript:history.go(-1)'>重新上传</a>]</font></div>"
end select
response.write str
else
response.write "<script language=""javascript"">parent.form2.pic.value='"&Uprequest.SavePath&Uprequest.Form("file")&"';"
response.write "</script>"
response.write "</script>"
size=Uprequest.Form("file_size")
showsize=size & " Byte"
if size>1024 then
size=(size\1024)
showsize=size & " KB"
end if
if size>1024 then
size=(size/1024)
showsize=formatnumber(size,2) & " MB"
end if
response.write "<script language=""javascript"">parent.form2.url.value='"&showsize&"';"
response.write "</script>"
response.write "<div style=""padding-top:5px;padding-bottom:5px;""> <font color=red>文件上传成功</font> [<a href='javascript:history.go(-1)'>重新上传</a>]</div>"
end if
Set Uprequest=nothing
end if
response.write "<form name=form action=?action=pic&submit=pic method=post enctype=multipart/form-data>"
response.write "<input type=file name=file class='tx' size='20'> "
response.write "<input type=submit name=submit value=上传 class=""tx1"">"
response.write "</form>"
end sub
%>

④ asp代码怎样实现无组件上传

一、无组件上传的原理
我还是一点一点用一个实例来说明的吧,客户端HTML如下。要浏览上传附件,我们通过<input type="file">元素,但是一定要注意必须设置form的enctype属性为"multipart/form-data":

<form method="post" action="upload.asp" enctype="multipart/form-data">
<label>
<input type="file" name="file1" />
</label>

<input type="text" name="filename" value="default filename"/>

<input type="submit" value="Submit"/>
<input type="reset" value="Reset"/>
</form>

在后台asp程序中,以前获取表单提交的ASCII 数据,非常的容易。但是如果需要获取上传的文件,就必须使用Request对象的BinaryRead方法来读取。BinaryRead方法是对当前输入流进行指定字节数的二进制读取,有点需要注意的是,一旦使用BinaryRead 方法后,再也不能使用Request.Form 或 Request.QueryString 集合了。结合Request对象的TotalBytes属性,可以将所有表单提交的数据全部变成二进制,不过这些数据都是经过编码的。首先让我们来看看这些数据是如何编码的,有无什么规律可循,编段代码,在代码中我们将BinaryRead读取的二进制转化为文本,输出出来,在后台的upload.asp中(注意该示例不要上传大文件,否则可能会造成浏览器死掉):
<%
Dim biData, PostData
Size = Request.TotalBytes
biData = Request.BinaryRead(Size)
PostData = BinaryToString(biData,Size)
Response.Write "<pre>" & PostData & "</pre>" '使用pre,原样输出格式
' 借助RecordSet将二进制流转化成文本
Function BinaryToString(biData,Size)
Const adLongVarChar = 201
Set RS = CreateObject("ADODB.Recordset")
RS.Fields.Append "mBinary", adLongVarChar, Size
RS.Open
RS.AddNew
RS("mBinary").AppendChunk(biData)
RS.Update
BinaryToString = RS("mBinary").Value
RS.Close
End Function
%>

⑤ ASP中上传图片怎么做啊

采用无组件下载代码。
upfile.asp

<% 'OPTION EXPLICIT%>
<!--#include FILE="upload_5xsoft.inc"-->

<%
dim upload,file,formName,formPath,iCount,MyFile
set upload=new upload_5xSoft ''建立上传对象

formpath="userdata/" ''得到上传目录

nian=Year(Date)
yue=Month(Date)
ri=Day(Date)
if len(nian)<4 then nian="00"&nian
if len(yue)<2 then yue="0"&yue
if len(ri)<2 then ri="0"&ri

ipinit=""
ip=Request.ServerVariables("REMOTE_ADDR")
tmpip=Split(ip,".")
tmpipb=UBound(tmpip)
' ReDim ThisIP(tmpipb)
for i=0 to tmpipb
ThisIp=tmpip(i)

Do WHile len(ThisIP)<3
ThisIP="0"+ThisIP
loop
ipinit=ipinit+ThisIP
next

'Response.write nian&yue&ri&ipinit
'Response.end

for each formName in upload.file ''列出所有上传了的文件
set file=upload.file(formName) ''生成一个文件对象
if file.FileSize>0 then ''如果 FileSize > 0 说明有文件数据
'MyFile=formPath&File.FileName
'MyFile=File.FileName

shi=Hour(time)
fen=Minute(Time)
Miao=Second(Time)
if len(shi)<2 then shi="0"&shi
if len(fen)<2 then fen="0"&fen
if len(miao)<2 then miao="0"&miao

MyFile=nian&yue&ri&shi&fen&miao&ipinit&".txt"

file.SaveAs Server.mappath(formPath&MyFile) ''保存文件
response.write file.FilePath&"#"&file.FileName&"#"&" ("&file.FileSize&") => "&MyFile&" 成功!<br>"
end if
set file=nothing
next
set upload=nothing ''删除此对象

%>

upload_5xsoft.inc

<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>

dim upfile_5xSoft_Stream

Class upload_5xSoft

dim Form,File,Version

Private Sub Class_Initialize
dim iStart,iFileNameStart,iFileNameEnd,iEnd,vbEnter,iFormStart,iFormEnd,theFile
dim strDiv,mFormName,mFormValue,mFileName,mFileSize,mFilePath,iDivLen,mStr
Version="HTTP上传程序 Version 1.0"
if Request.TotalBytes<1 then Exit Sub
set Form=CreateObject("Scripting.Dictionary")
set File=CreateObject("Scripting.Dictionary")
set upfile_5xSoft_Stream=CreateObject("Adodb.Stream")
upfile_5xSoft_Stream.mode=3
upfile_5xSoft_Stream.type=1
upfile_5xSoft_Stream.open
upfile_5xSoft_Stream.write Request.BinaryRead(Request.TotalBytes)

vbEnter=Chr(13)&Chr(10)
iDivLen=inString(1,vbEnter)+1
strDiv=subString(1,iDivLen)
iFormStart=iDivLen
iFormEnd=inString(iformStart,strDiv)-1
while iFormStart < iFormEnd
iStart=inString(iFormStart,"name=""")
iEnd=inString(iStart+6,"""")
mFormName=subString(iStart+6,iEnd-iStart-6)
iFileNameStart=inString(iEnd+1,"filename=""")
if iFileNameStart>0 and iFileNameStart<iFormEnd then
iFileNameEnd=inString(iFileNameStart+10,"""")
mFileName=subString(iFileNameStart+10,iFileNameEnd-iFileNameStart-10)
iStart=inString(iFileNameEnd+1,vbEnter&vbEnter)
iEnd=inString(iStart+4,vbEnter&strDiv)
if iEnd>iStart then
mFileSize=iEnd-iStart-4
else
mFileSize=0
end if
set theFile=new FileInfo
theFile.FileName=getFileName(mFileName)
theFile.FilePath=getFilePath(mFileName)
theFile.FileSize=mFileSize
theFile.FileStart=iStart+4
theFile.FormName=FormName
file.add mFormName,theFile
else
iStart=inString(iEnd+1,vbEnter&vbEnter)
iEnd=inString(iStart+4,vbEnter&strDiv)

if iEnd>iStart then
mFormValue=subString(iStart+4,iEnd-iStart-4)
else
mFormValue=""
end if
form.Add mFormName,mFormValue
end if

iFormStart=iformEnd+iDivLen
iFormEnd=inString(iformStart,strDiv)-1
wend
End Sub

Private Function subString(theStart,theLen)
dim i,c,stemp
upfile_5xSoft_Stream.Position=theStart-1
stemp=""
for i=1 to theLen
if upfile_5xSoft_Stream.EOS then Exit for
c=ascB(upfile_5xSoft_Stream.Read(1))
If c > 127 Then
if upfile_5xSoft_Stream.EOS then Exit for
stemp=stemp&Chr(AscW(ChrB(AscB(upfile_5xSoft_Stream.Read(1)))&ChrB(c)))
i=i+1
else
stemp=stemp&Chr(c)
End If
Next
subString=stemp
End function

Private Function inString(theStart,varStr)
dim i,j,bt,theLen,str
InString=0
Str=toByte(varStr)
theLen=LenB(Str)
for i=theStart to upfile_5xSoft_Stream.Size-theLen
if i>upfile_5xSoft_Stream.size then exit Function
upfile_5xSoft_Stream.Position=i-1
if AscB(upfile_5xSoft_Stream.Read(1))=AscB(midB(Str,1)) then
InString=i
for j=2 to theLen
if upfile_5xSoft_Stream.EOS then
inString=0
Exit for
end if
if AscB(upfile_5xSoft_Stream.Read(1))<>AscB(MidB(Str,j,1)) then
InString=0
Exit For
end if
next
if InString<>0 then Exit Function
end if
next
End Function

Private Sub Class_Terminate
form.RemoveAll
file.RemoveAll
set form=nothing
set file=nothing
upfile_5xSoft_Stream.close
set upfile_5xSoft_Stream=nothing
End Sub

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

Private function toByte(Str)
dim i,iCode,c,iLow,iHigh
toByte=""
For i=1 To Len(Str)
c=mid(Str,i,1)
iCode =Asc(c)
If iCode<0 Then iCode = iCode + 65535
If iCode>255 Then
iLow = Left(Hex(Asc(c)),2)
iHigh =Right(Hex(Asc(c)),2)
toByte = toByte & chrB("&H"&iLow) & chrB("&H"&iHigh)
Else
toByte = toByte & chrB(AscB(c))
End If
Next
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=1
if trim(fullpath)="" or FileSize=0 or FileStart=0 or FileName="" then exit function
if FileStart=0 or right(fullpath,1)="/" then exit function
set dr=CreateObject("Adodb.Stream")
dr.Mode=3
dr.Type=1
dr.Open
upfile_5xSoft_Stream.position=FileStart-1
upfile_5xSoft_Stream.to dr,FileSize
dr.SaveToFile FullPath,2
dr.Close
set dr=nothing
SaveAs=0
end function
End Class
</SCRIPT>

⑥ 求asp有上传进度条的无组件上传代码

艾恩Ajax无刷新上传高级上传实例

本上传使用的类为本人原创上传类,经修改后用于无刷新上传(普通上传同样可用)
详细显示上传过程,包括进度条,上传百分比,总上传数据大小,当前上传数据大小,上传进程时间等。。。

进度条样式可自行修改,样式文件为css.css
具体进程信息请查看js/custom.js中的getInformation(info)中的信息对象的说明

本次给上传类增加了一个方法setApp,用来设置Application;
调用方法Upload.setApp state,total,current,description
参数说明:
state--当前状态,建议取值请查看js/custom.js中的getInformation(info)函数中的状态说明
total--总上传数据大小
current--已上传数据大小
description--描述,主要是在出现错误的时候使用,一般使用空值即可

请保留upload.asp中对Application的设置(共四处,最后一处可选择性删除)

下载 : http://down.chinaz.com/soft/24892.htm

⑦ ASP 无组件上传文件:怎么把文件存在指定的文件夹里

在这个ASP上传类中,一般会有一个Save或者SaveAs方法,参数是要保存的文件地址。如
myUpLoad.SaveAs "D:\FileUpload\Test.rar"

一般网上下载的ASP无组件下载类都附带有一套简单的示例文件,可以好好看看。

阅读全文

与asp无组件上传代码下载相关的资料

热点内容
c语言程序设计迷宫 浏览:692
js获取主机名称 浏览:3
京东物流的app有哪些 浏览:244
网站中木马怎么办 浏览:969
文件夹折法 浏览:223
计算机编程等级怎么划分 浏览:551
怎么给文件夹重命名 浏览:670
win10解密文件重装系统 浏览:384
大淘营相册搬家工具 浏览:538
c盘数字文件夹 浏览:919
数据挖掘应用在哪些领域 浏览:733
大陆天龙八部dvd版本 浏览:919
启动镜像文件 浏览:999
哪个网站看言情小说最全 浏览:853
苹果手机如何下载拣货app 浏览:971
户外跑步app 浏览:993
电脑免费素材app有哪些 浏览:631
quq是什么意思网络用语 浏览:284
博途gsd怎么编程 浏览:76
外语字典app有哪些 浏览:457

友情链接