删除网站里无用的图片
某产品管理系统做的不完善,删除产品记录的时候,指定图片没有删除,现在要来个大清理。
<!--#include file="inc/conn.asp"-->
<%
Dim strSql,currentPath
Dim Fso
Set Fso = Server.CreateObject("Scripting.FileSystemObject")
Dim Fol
currentPath = Server.MapPath("product_pic")
If Fso.FolderExists(currentPath) Then
Dim RS
Set RS = Server.CreateObject("ADODB.RecordSet")
Set Fol=Fso.GetFolder(currentPath)
Set Fles=Fol.Files
For Each Item In Fles
strSql = "Select * from product where productPicture='" & Item.Name & "'"
RS.Open strSql,conn
If RS.EOF Then
Fso.DeleteFile currentPath & "\" & Item.Name
End If
RS.Close
Next
Set RS = nothing
Else
Response.Write "目录不存在。"
Response.End
End If
conn.close
Set conn = nothing
%>
清理完毕