【頂】Asp無組件產生縮圖(2)

來源:互聯網
上載者:User
現在我們先設計一個showimg.asp頁面用來顯示縮圖及相關資訊。具體設計如下:

  圖片:

  圖片格式:

  圖片尺寸:

  圖片大小:

  點擊次數:

  下面,我們擷取圖片的絕對路徑。代碼如下:
<%
/////擷取showimg.asp的絕對路徑/////
dim curfile
curfile=server.mappath(request.servervariables("path_info"))
dim curfilename,filename

/////圖片相對路徑(存於資料庫中)
cufilename=rs("imgurl")

/////因為showimg.asp與images在同一目錄,所以我們用instrrev擷取images的路徑/////
filename=left(curfile,instrrev(curfile,"\"))&cufilename

/////建立gps類實體/////
dim getpicsize
set getpicsize=new gps
set fs=server.createobject("scripting.filesystemobject")

/////擷取圖片類型/////
dim picsuffixname
picsuffixname=fs.getextensionname(filename)
dim pd //picture dimension
dim pwidth,pheight
select case picsuffixname
case "gif","bmp","jpg","png":

/////調用gps通用類中的getimagesize函數擷取圖片尺寸/////
pd=getpicsize.getimagesize(filename)
pwidth=pd(1) //擷取圖片寬度
pheight=pd(2) //擷取圖片高度
case "swf"
pd=getpicsize.getimagesize(filename)
pwidth=pd(1) //擷取flash寬度
pheight=pd(2) //擷取flash高度
case else
end select
set fs=nothing
set getpicsize=nothing
%>

  將上面的代碼複製到<body>的上面就ok了!

  當然,有人會說,擷取路徑不一定要用path_info,直接用server.mappath()不就可以了嘛,呵呵,蘿蔔青菜各有所愛,主要是我用path_info可以實現fso的一些功能而用server.mappath()沒有搞定,所以一直使用這個。



文章整理:站長天空 網址:http://www.z6688.com/
以上資訊與文章本文是不可分割的一部分,如果您要轉載本文章,請保留以上資訊,謝謝!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.