·您的位置: 首页 » 资源教程 » 编程开发 » ASP » 一个ASP版的图片浏览管理器

一个ASP版的图片浏览管理器

类别: ASP教程  评论数:0 总得分:0
下面是很简洁的代码
<%@ Language=VBScript %>
<% Option Explicit %>
<%
Const ImageFilePath = "images"
Const DeleteButtonLabel = "Delete Selected Images"

Dim objFSO
Dim objFolder
Dim objFile

Dim strFileName
Dim strFileExtension

Dim blnShowImages

If Request.QueryString("ShowImages") = "" Then
blnShowImages = False
Else
blnShowImages = CBool(Request.QueryString("ShowImages"))
End If

If Request.Form("btnDelete") = DeleteButtonLabel Then
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

For Each strFileName In Request.Form("delete")
objFSO.DeleteFile(Server.MapPath(ImageFilePath & "/" & _
strFileName))
Next

Set objFSO = Nothing
End If
%>
<html>
<head>
<title>ASP 101 Image Browser & Killer!</title>
</head>
<body>

<form action="<%= Request.ServerVariables("URL") %>" method="post">

<table border="1">
<tr>
<th>Image Name</th>
<th>Image <a href="<%= Request.ServerVariables("URL") %>?
ShowImages=<%= Not blnShowImages %>">(Toggle Display)</a></th>
<th>Delete This Image</th>
</tr>
<%
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(Server.MapPath(ImageFilePath))

For Each objFile In objFolder.Files
strFileExtension = LCase(Mid(objFile.Name, _
InStrRev(objFile.Name, ".", -1, 1) + 1))

If strFileExtension = "gif" Or strFileExtension = "jpg" Or _
strFileExtension = "jpeg" Then
\' Original image file identification option:
\'If objFile.Type = "GIF Image" Or _
objFile.Type = "JPEG Image" Then
%>
<tr>
<td>
<a href="<%= ImageFilePath & "/" & objFile.Name %>">
<%= objFile.Name %></a>
</td>
<%
If blnShowImages Then
%>
<td>
<img src="<%= ImageFilePath & "/" & objFile.Name %>" />
</td>
<%
Else
%>
<td>
<a href="<%= ImageFilePath & "/" & objFile.Name %>">
View Image</a>
</td>
<%
End If
%>
<td align="center">
<input type="checkbox" name="delete"
value="<%= objFile.Name %>" />
</td>
<%
End If
Next

Set objFolder = Nothing
Set objFSO = Nothing
%>
<tr>
<td colspan="3" align="right">
<input type="submit" name="btnDelete"
value="<%= DeleteButtonLabel %>">
</td>
</tr>
</table>

</form>

</body>
</html>

执行删除操作时,一定要注意,如果在程序里不加删除确认提示,程序将不能撤消删除操作。
-= 资 源 教 程 =-
文 章 搜 索
关键词:
类型:
范围:
纯粹空间 softpure.com
Copyright © 2006-2008 暖阳制作 版权所有
QQ: 15242663 (拒绝闲聊)  Email: faisun@sina.com
 纯粹空间 - 韩国酷站|酷站欣赏|教程大全|资源下载|免费博客|美女壁纸|设计素材|技术论坛   Valid XHTML 1.0 Transitional
百度搜索 谷歌搜索 Alexa搜索 | 粤ICP备19116064号-1