Asp无组件生成缩略图 [2]

现在我们先设计一个ShowImg.asp页面用来显示缩略图及相关信息。具体设计如下:

图片:

图片格式:

图片尺寸:

图片大小:

点击次数:

下面,我们获取图片的绝对路径。代码如下:

 1   
 2'/////获取ShowImg.asp的绝对路径/////   
 3Dim curFile   
 4curFile=Server.mappath(Request.servervariables("PATH_INFO"))   
 5Dim curfilename,filename 
 6
 7'/////图片相对路径(存于 数据库 中)   
 8cufilename=rs("ImgURL") 
 9
10'/////因为ShowImg.asp与images在同一目录,所以我们用instrrev获取images的路径/////   
11filename=left(curFile,instrrev(curFile,"\"))&cufilename 
12
13'/////建立GPS类实体/////   
14Dim GetPicSize   
15Set GetPicSize=new GPS   
16Set fs=Server.CreateObject("Scripting.FileSystemObject") 
17
18'/////获取图片类型/////   
19Dim PicSuffixName   
20PicSuffixName=fs.GetExtensionName(filename)   
21Dim PD '//Picture Dimension   
22Dim PWidth,PHeight   
23Select Case PicSuffixName   
24Case "gif","bmp","jpg","png": 
25
26'/////调用GPS通用类中的GetImageSize函数获取图片尺寸/////   
27PD=GetPicSize.GetImageSize(filename)   
28PWidth=PD(1) '//获取图片宽度   
29PHeight=PD(2) '//获取图片高度   
30Case "swf"   
31PD=GetPicSize.GetImageSize(filename)   
32PWidth=PD(1) '//获取Flash宽度   
33PHeight=PD(2) '//获取Flash高度   
34Case Else   
35End Select   
36Set fs=Nothing   
37Set GetPicSize=Nothing   

将上面的代码复制到

1<body>的上面就OK了! 
2
3当然,有人会说,获取路径不一定要用PATH_INFO,直接用server.mappath()不就可以了嘛,呵呵,萝卜青菜各有所爱,主要是我用PATH_INFO可以实现FSO的一些功能而用server.mappath()没有搞定,所以一直使用这个。</body>
Published At
Categories with Web编程
comments powered by Disqus