用asp如何获得服务器文件夹的图片的宽度和高度

用asp如何获得服务器文件夹的图片的宽度和高度,第1张

ASP本身不能实现该功能,但是可以用具有读写二进制文件功能的AdodbStream对象来间接实现

<%

'下面这段即可获得你要的那的宽和高

imgpath="images/photo/abcjpg"

set pp=new imgInfo

w = ppimgW(servermappath(imgpath))

h = ppimgH(servermappath(imgpath))

set pp=nothing

%>

<%

'这一段是所要用的类

Class imgInfo

dim aso

Private Sub Class_Initialize

set aso=CreateObject("AdodbStream")

asoMode=3

asoType=1

asoOpen

End Sub

Private Sub Class_Terminate

errclear

set aso=nothing

End Sub

Private Function Bin2Str(Bin)

Dim I, Str

For I=1 to LenB(Bin)

clow=MidB(Bin,I,1)

if ASCB(clow)<128 then

Str = Str & Chr(ASCB(clow))

else

I=I+1

if I <= LenB(Bin) then Str = Str & Chr(ASCW(MidB(Bin,I,1)&clow))

end if

Next

Bin2Str = Str

End Function

Private Function Num2Str(num,base,lens)

dim ret

ret = ""

while(num>=base)

ret = (num mod base) & ret

num = (num - num mod base)/base

wend

Num2Str = right(string(lens,"0") & num & ret,lens)

End Function

Private Function Str2Num(str,base)

dim ret

ret = 0

for i=1 to len(str)

ret = ret base + cint(mid(str,i,1))

next

Str2Num=ret

End Function

Private Function BinVal(bin)

dim ret

ret = 0

for i = lenb(bin) to 1 step -1

ret = ret 256 + ascb(midb(bin,i,1))

next

BinVal=ret

End Function

Private Function BinVal2(bin)

dim ret

ret = 0

for i = 1 to lenb(bin)

ret = ret 256 + ascb(midb(bin,i,1))

next

BinVal2=ret

End Function

Private Function getImageSize(filespec)

dim ret(3)

asoLoadFromFile(filespec)

bFlag=asoread(3)

select case hex(binVal(bFlag))

case "4E5089":

asoread(15)

ret(0)="PNG"

ret(1)=BinVal2(asoread(2))

asoread(2)

ret(2)=BinVal2(asoread(2))

case "464947":

asoread(3)

ret(0)="GIF"

ret(1)=BinVal(asoread(2))

ret(2)=BinVal(asoread(2))

case "535746":

asoread(5)

binData=asoRead(1)

sConv=Num2Str(ascb(binData),2 ,8)

nBits=Str2Num(left(sConv,5),2)

sConv=mid(sConv,6)

while(len(sConv)<nBits4)

binData=asoRead(1)

sConv=sConv&Num2Str(ascb(binData),2 ,8)

wend

ret(0)="SWF"

ret(1)=int(abs(Str2Num(mid(sConv,1nBits+1,nBits),2)-Str2Num(mid(sConv,0nBits+1,nBits),2))/20)

ret(2)=int(abs(Str2Num(mid(sConv,3nBits+1,nBits),2)-Str2Num(mid(sConv,2nBits+1,nBits),2))/20)

case "FFD8FF":

do

d p1=binVal(asoRead(1)): loop while p1=255 and not asoEOS

if p1>191 and p1<196 then exit do else asoread(binval2(asoRead(2))-2)

dp1=binVal(asoRead(1)):loop while p1<255 and not asoEOS

loop while true

asoRead(3)

ret(0)="JPG"

ret(2)=binval2(asoRead(2))

ret(1)=binval2(asoRead(2))

case else:

if left(Bin2Str(bFlag),2)="BM" then

asoRead(15)

ret(0)="BMP"

ret(1)=binval(asoRead(4))

ret(2)=binval(asoRead(4))

else

ret(0)=""

end if

end select

ret(3)="width=""" & ret(1) &""" height=""" & ret(2) &""""

getimagesize=ret

End Function

Public Function imgW(pic_path)

Set fso1 = serverCreateObject("ScriptingFileSystemObject")

If (fso1FileExists(pic_path)) Then

Set f1 = fso1GetFile(pic_path)

ext=fso1GetExtensionName(pic_path)

select case ext

case "gif","bmp","jpg","png":

arr=getImageSize(f1path)

imgW = arr(1)

end select

Set f1=nothing

else

imgW = 0

End if

Set fso1=nothing

End Function

Public Function imgH(pic_path)

Set fso1 = serverCreateObject("ScriptingFileSystemObject")

If (fso1FileExists(pic_path)) Then

Set f1 = fso1GetFile(pic_path)

ext=fso1GetExtensionName(pic_path)

select case ext

case "gif","bmp","jpg","png":

arr=getImageSize(f1path)

imgH = arr(2)

end select

Set f1=nothing

else

imgH = 0

End if

Set fso1=nothing

End Function

End Class

%>

可以通过RequestServerVariables("HTTP_REFERER")来获得来源地址;

ASP语言中的RequestServerVariables可以获取服务器变量的值,包括主机的ip,执行的脚步路径,请求来源的地址等,和PHP的$_SERVER,JSP的requestgetHeader()类似,都是获取服务器一些配置变量和http请求的头信息;

 ASP是动态服务器页面(Active Server Page)的英文缩写。是微软公司开发的代替CGI脚本程序的一种应用,它可以与数据库和其它程序进行交互,是一种简单、方便的编程工具。ASP的网页文件的格式是 asp,现在常用于各种动态网站中。由于asp有众多漏洞,再加上微软支持aspnet,asp开发已经处于淘汰状态,目前web开发,已经是PHP,JSP和NET三家天下。

那要看你是怎么访问的了

如果你在IE中输入的是

127001或19216812

当然是得到内网的了

如果你直接输入公网IP再试试

而且本机IIS 优先的还是本机访问 所以它先判断是否是内网访问的

主要看你通过什么访问 如果以后你传到服务器 经过域名解析后 肯定能得到公网的IP了

DABAN RP主题是一个优秀的主题,极致后台体验,无插件,集成会员系统
网站模板库 » 用asp如何获得服务器文件夹的图片的宽度和高度

0条评论

发表评论

提供最优质的资源集合

立即查看 了解详情