I have the following script that lists the files in a different directory and generates hyperlinks to them to download them with a check box next to them. I want to be able to delete the selected files I know I can use the file system object to delete files, just don't know how to have it loop through and delete each of the selected files. I would also like to have this submit to itself, and call a function on submit to handle the delete, instead of having 2 different asp files. Here is current source:
<%@ Language=VBScript %>
<HTML>
<HEAD>
<TITLE>Gungor Productions File Exchange</TITLE>
<style>
BODY {background-color: white;font-family:arial; font-size:12}
</style>
</HEAD>
<BODY>
<p align="center"><b><font size="5">Gungor Productions File Exchange Management Interface</font></b></p>
<div style="border-bottom: #A91905 2px solid;font-size:16"><br><strong>Select files to delete from Server:</strong></div>
<%
Dim strPath 'Path of directory to show
Dim objFSO
Dim objFolder
Dim objItem
strPath="./files"
Set objFSO = Server.CreateObject("Scripting.FileSystemObject"
Set objFolder = objFSO.GetFolder(Server.MapPath(strPath))
response.write "<form method=""POST"" action=""manage.asp"" onSubmit=""return onSubmitForm();""><TABLE>" &_
"<tr><TD></TD><TD><strong>File Name</td></strong>" &_
"<TD><strong>Size</strong></TD></TR>"
For Each objItem In objFolder.Files
response.write "<tr><TD><input type=""checkbox"" name=""" & objItem.Name & """ value=""ON""></TD><TD><A HREF=""" &_
strPath & objItem.Name &_
""">" & objItem.Name & "</A></TD>" &_
"<TD>" & objItem.Size & "</TD></TR>"
Next
response.write "</TABLE><p><input type=""submit"" value=""Delete Selected Files"" name=""B1""></p></form>"
Set objItem = Nothing
Set objFolder = Nothing
Set objFSO = Nothing
%>
<p align="right"><font face="Verdana" size="1">©2004, Gungor Productions.
All Rights Reserved.</font></p>
</BODY>
</HTML>
<%@ Language=VBScript %>
<HTML>
<HEAD>
<TITLE>Gungor Productions File Exchange</TITLE>
<style>
BODY {background-color: white;font-family:arial; font-size:12}
</style>
</HEAD>
<BODY>
<p align="center"><b><font size="5">Gungor Productions File Exchange Management Interface</font></b></p>
<div style="border-bottom: #A91905 2px solid;font-size:16"><br><strong>Select files to delete from Server:</strong></div>
<%
Dim strPath 'Path of directory to show
Dim objFSO
Dim objFolder
Dim objItem
strPath="./files"
Set objFSO = Server.CreateObject("Scripting.FileSystemObject"
Set objFolder = objFSO.GetFolder(Server.MapPath(strPath))
response.write "<form method=""POST"" action=""manage.asp"" onSubmit=""return onSubmitForm();""><TABLE>" &_
"<tr><TD></TD><TD><strong>File Name</td></strong>" &_
"<TD><strong>Size</strong></TD></TR>"
For Each objItem In objFolder.Files
response.write "<tr><TD><input type=""checkbox"" name=""" & objItem.Name & """ value=""ON""></TD><TD><A HREF=""" &_
strPath & objItem.Name &_
""">" & objItem.Name & "</A></TD>" &_
"<TD>" & objItem.Size & "</TD></TR>"
Next
response.write "</TABLE><p><input type=""submit"" value=""Delete Selected Files"" name=""B1""></p></form>"
Set objItem = Nothing
Set objFolder = Nothing
Set objFSO = Nothing
%>
<p align="right"><font face="Verdana" size="1">©2004, Gungor Productions.
All Rights Reserved.</font></p>
</BODY>
</HTML>