Browser This is my first translation of articles, deficiencies, but also please forgive me.
India, which is now a major exporter of software, is superior to us in many places. One of the first advantages is that the official language of India is English, which gives the Indian programmer with English as the programming language the advantageous condition. For those of us in the IT industry, we should also strengthen our own English training. First of all, thank CSDN for providing such a platform. Gossip is not much said, the text is as follows:
Introduction
If you have a website that has been running for more than two months, you may notice that you have amassed a lot of picture files on your site. Although we've all tried to name these picture files well, when we go through the file names of these pictures, it's always hard to remember the special meaning or usefulness of some picture filenames.
At this point, we usually use the browser to open the pictures repeatedly, to see what is the picture? At this point, the ASP code can be used as a picture browser (and cleaner) to browse these pictures and perform cleanup operations.
Coding:
In fact, the program is a list page that contains all the pictures in a directory, using the FileSystemObject object to enumerate the image files (GIF and JPEG files).
Add a link toggle display in the page to control whether the picture is displayed. When you have a lot of files that you don't want to load, you can just let a picture of the page show a link, and conversely, if you're unsure about the meaning of some file naming, this feature will help you clean up.
Here's a neat code.
<%@ 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
%>
<title>asp Image Browser & killer!</title>
<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>
</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>
When performing a delete operation, be sure to note that the program cannot undo the deletion if you do not delete the confirmation prompt in your program.
Conclusion
People never use ASP to build large, scalable Web sites. (Translator Note: This sentence does not translate is not very appropriate, according to my work experience, the ASP can completely build large-scale website system. In the ASP aspect, I have participated in the construction large-scale enterprise intranet, the mobile industry application and so on. But sometimes you can use this to simplify your work, even if the code is never published on the web.
Get code
You can download the zip file Http://www.asp101.com/articles/john/imageviewer/imgview.zip containing the discussion of this code. To control the size of the file, I did not include a picture example. I remind you once again that it is easy to use this code to destroy and delete a lot of related pictures. Be aware that when you do not delete the confirmation, you are sure to use a copy of the picture to operate.
Code updates