当前位置:首页 > 代码 > 正文

asp视频上传代码(asp上传大文件)

admin 发布:2023-05-17 09:00 102


本篇文章给大家谈谈asp视频上传代码,以及asp上传大文件对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

高分求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_Error4 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 lngRequestSize1 or (lngRequestSizep_TotalSize and p_TotalSize0) 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,bCrLfbCrLf)+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=strFileItemstrSplitstrInam

if binItem.Size0 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_AutoSave2 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_SavePathstrFnam),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=strFormItemstrSplitstrInam

objForm.Add strInam,strTemp

end if

end if

binItem.Close()

p_start = p_end+intSeparator+2

loop Until p_start+3lngRequestSize

FormItem=split(strFormItem,strSplit)

FileItem=split(strFileItem,strSplit)

End Sub

Private Function GetTimeStr()

lngTime=lngTime+1

GetTimeStr=strDatelngTime

End Function

Private Function GetFerr(lngFsiz,strFext)

dim intFerr

intFerr=0

if lngFsizp_MaxSize and p_MaxSize0 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_Error2 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 intFerr0 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_SavePathstrFnam),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.SavePathrequest2.Form("strFile1")

'在提交数据库页面把文件路径和文件名写入表单以供提交

response.write "scriptparent.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"

brbr

input name="content" type="text" id="content"

briframe 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 "scriptparent.document.form1.content.value='" ming "'/script" 这个是把上传得到的文件名和路径写入你要提交的表单,还有你自己的页面要用iframe调用up.asp。还有什么不懂的可以QQ问我:54660142

asp上传视频到指定文件夹并写入文件名到数据库代码

李庆%

'response.BinaryWrite(request.BinaryRead(request.TotalBytes))''''''1

dim data, datalength,fstart,fend,tstart,tend,tinfo,flag,flaglen,tformname,tfile,tfilename,tfileparth,tfileext,sfilename

set formdata=server.CreateObject("scripting.dictionary")

set updata=server.CreateObject("adodb.stream")

set tmpdata=server.CreateObject("adodb.stream")

updata.mode=3

updata.type=1

updata.open

updata.write(request.BinaryRead(request.TotalBytes))

updata.position=0

data=updata.read

datalength=updata.size

tcrlf=chrb(13) chrb(10)

flag=leftb(data,instrb(data,tcrlf)-1)

fstart=lenb(flag)+2

flaglen=fstart

do

fend=instrb(fstart,data,tcrlftcrlf)+3

tmpdata.type=1

tmpdata.mode=3

tmpdata.open

updata.position=fstart

updata.copyto tmpdata,fend-fstart

fstart=instrb(fend,data,flag)-1

tmpdata.position=0

tmpdata.type=2

tmpdata.charset="gb2312"

tinfo=tmpdata.readtext

'response.Write tinfo''''''''''''''''''''''''''''''''''''''''''''''

tstart=instr(22,tinfo,"name=""")+6

'tstart=instr(tinfo,"name=""")+6'''''''''''''''''''''''''''''''''

tend=instr(tstart,tinfo,"""",1)

tformname=mid(tinfo,tstart,tend-tstart)

' response.Write(tformname)'''''''''''''''''''''

'if instr(tinfo,"filename=""")0 then'如果是文件

if instr(tstart,tinfo,"filename=""",1)0 then

tmpdata.close

tmpdata.type=1

tmpdata.mode=3

tmpdata.open

tstart=instr(tend,tinfo,"filename=""",1)+10

tend=instr(tstart,tinfo,"""",1)

tfile=mid(tinfo,tstart,tend-tstart)

'response.Write tinfo''''''''''

'response.Write "br/"''''''''''

'response.Write("tstart="tstart"br/")''''''''''''''''''''''''''''''''''''

'response.Write("tinfo.len="len(tinfo)"br/")

'response.Write("tend="tend"br/")

'response.Write "tfile="tfile"br/"

'if tfile"" then''''''''''''''''哪散握'''''''''''''''''''''''''''''''''

' response.Write("no kong")''''''''''''''

'else'''''''''''''''''''''''''''''

'response.Write("kong")''''''''''

'end if'''''''''''''''''''''''''''''''''''''''''''''''''

if tfile"" then

tfilename=mid(tfile,instrrev(tfile,"\")+1)

tfilepath=left(tfile,instrrev(tfile,"\掘态"))

tfileext=mid(tfile,instrrev(tfile,".")+1)

sfilename=GetRndFileName(tfileext)

'response.Write(sfilename)''''''''''

updata.position=fend

updata.copyto tmpdata,fstart-2-fend

'response.BinaryWrite(tmpdata)''''''''2

tmpdata.savetofile server.MapPath("img_web") "\" sfilename,2

formdata.add tformname,sfilename

end if

else

tmpdata.close

tmpdata.type=1

tmpdata.mode=3

tmpdata.open

updata.position=fend

updata.copyto tmpdata,fstart-fend-2

tmpdata.position=0

tmpdata.type=2

tmpdata.charset="gb2312"

formdata.add tformname,tmpdata.readtext

end if

fstart=fstart+flaglen

tmpdata.close

loop while (fstart+2)datalength

set tmpdata=nothing

updata.close

set updada=nothing

'for each key in formdata.keys

' response.Write "表单控件名称:"key"值:" formdata.item(key)"br/"

'next

Function GetRndFileName(sExt)

dim sRnd

randomize

sRnd=int(900*rnd)+100

GetRndFileName=year(now())month(now())day(now())hour(now())minute(now())second(now())sRnd"."sExt

end function

%

给分吧

asp视频上传代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于asp上传大文件、asp视频上传代码的信息别忘了在本站进行查找喔。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/45043.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载