找个ASP无组件多图片文字上传到数据库原码 在线等

找个ASP无组件多图片文字上传到数据库原码 在线等,第1张

<%

我在用的

'----------------------------------------------------------

'***************** 风声无组件上传类 2.0 *****************

'作者:风声

'网站:http://www.17560.net http://www.54nb.com

'邮件:[email protected]

'版权:版权全体,源代码公开,各种用途均可免费使用

'**********************************************************

'----------------------------------------------------------

class uploadclass

private p_maxsize,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.0"

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 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/doc/txt/htm/html/xls/rar/zip/mp3"

p_savepath = "../../wj/"

p_autosave = 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

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 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

%>

inc/#4ifkejuwemcjew.asp

这个就是数据库的地址。你要是想看的话,就把后缀名改成.mdb的。他改成.asp。就是为了防下载。浏览完,记得在把后缀名改为.asp的,不然你的系统用不了


欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/sjk/9520570.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-29
下一篇 2023-04-29

发表评论

登录后才能评论

评论列表(0条)

保存