- 作者:xiaoxiao
- 发表时间:2020-12-23 11:02
- 来源:未知
<% @ LANGUAGE="VBSCRIPT" CODEPAGE="936"%><%Option Explicit
Class BoxInfoImg'传输类的使用方法'图象上传和上传信息获取CLASS
'用法:'dim imgUp'set imgUp=new BoxInfoImg
'属性: 'imgUp.width '宽'imgUp.height '高'imgUp.imgSize '大小'imgUp.imgType '类型'imgUp.imgName '文件名'imgUp.imgName '图像文件名:"&'imgUp.filename '文件名"&'imgUp.extName '扩展名"'imgUp.DiskPath '保存位置"'imgUp.XuPath '虚拟路径"'imgUp.NewUrl '保存后url"'imgUp.SaveMode '保存后url"
'方法:'imgUp.saveImg(fullpath) '保存图像文件
dim ADOSdim width,height,imgSize,imgType,imgName,fileNamedim preName,extNamedim SavePath,SaveName,SaveModedim DiskPath,XuPath,NewUrldim textStrdim i
Private Sub Class_Initializeset ADOS=Server.CreateObject("Adodb.Stream")ADOS.Type=1 ADOS.Mode=3 ADOS.Open getImageSizeEnd Sub
Private Sub Class_TerminateADOS.closeset ADOS=nothingEnd Sub
Public Function getImageSize()
dim ret(3),bFlag,fdata,fsize
fdata=GetWebData(GetStrUrl) '取得XmlHttp数据fsize=clng(lenb(fdata)) '取得数据尺寸
if fsize=0 then exit function R_write "无有效数据保存",0end if
ADOS.Write fdata ADOS.Position=0
SaveName=iSaveNameSavePath=iSavePathSaveMode=iSaveMode
'写文本对象读取图像长宽和类型
ADOS.Position=0 '重置数据开始位置 bFlag=ADOS.read(3)
if isNull(bFlag) then width=0height=0imgSize=0imgType="unknow"ret(0)=imgType:ret(1)=width:ret(2)=height:ret(3)=""getimagesize=retexit functionend if
'取文件类型和长宽select case hex(binVal(bFlag))case "4E5089":ADOS.read(15)ret(0)="png"ret(1)=BinVal2(ADOS.read(2))ADOS.read(2)ret(2)=BinVal2(ADOS.read(2))case "464947":ADOS.read(3)ret(0)="gif"ret(1)=BinVal(ADOS.read(2))ret(2)=BinVal(ADOS.read(2))case "FFD8FF":dim p1do do: p1=binVal(ADOS.Read(1)): loop while p1=255 and not ADOS.EOSif p1>191 and p1<196 then exit do else ADOS.read(binval2(ADOS.Read(2))-2)do:p1=binVal(ADOS.Read(1)):loop while p1<255 and not ADOS.EOSloop while trueADOS.Read(3)ret(0)="jpg"ret(2)=binval2(ADOS.Read(2))ret(1)=binval2(ADOS.Read(2))case else:if left(Bin2Str(bFlag),2)="BM" thenADOS.Read(15)ret(0)="bmp"ret(1)=binval(ADOS.Read(4))ret(2)=binval(ADOS.Read(4))elseret(0)=""end ifend select'dim tempStrdim nameStrdim defaultNamedim lntempStr=split(GetStrUrl,"/")nameStr=tempStr(ubound(tempStr))if nameStr="" thenr_write "错误的URL,请输入可访问的URL",0exit functionend iffileName=split(nameStr,"?")(0)ln=inStrRev(fileName,".")if ln>0 then preName=left(fileName,inStrRev(fileName,".")-1)elsepreName=fileNameend if'R_write fileName,1'R_write inStrRev(fileName,"."),1'R_write fileName,0extName=right(fileName,len(fileName)-inStrRev(fileName,"."))