Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete selected files

Status
Not open for further replies.

chellweg

IS-IT--Management
Dec 8, 2003
20
US
I have the following script that lists the files in a different directory and generates hyperlinks to them to download them. I want to be able to but a check box to the left of every file that is listed and have a delete selected files button at the bottom of the list. I know I can use the file system object to delete files, just don't know how to add the box and button to delete the 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=&quot;center&quot;><b><font size=&quot;5&quot;>Gungor Productions File Exchange Management Interface</font></b></p>
<div style=&quot;border-bottom: #A91905 2px solid;font-size:16&quot;><br><strong>Listing of Files on server:</strong></div>
<%
Dim strPath 'Path of directory to show
Dim objFSO
Dim objFolder
Dim objItem
strPath=&quot;./files&quot;
Set objFSO = Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set objFolder = objFSO.GetFolder(Server.MapPath(strPath))
response.write &quot;<TABLE>&quot; &_
&quot;<tr><TD><strong>File Name</td></strong>&quot; &_
&quot;<TD><strong>Size</strong></TD></TR>&quot;
For Each objItem In objFolder.Files
response.write &quot;<tr><TD><A HREF=&quot;&quot;&quot; &_
strPath & objItem.Name &_
&quot;&quot;&quot;>&quot; & objItem.Name & &quot;</A></TD>&quot; &_
&quot;<TD>&quot; & objItem.Size & &quot;</TD></TR>&quot;
Next
response.write &quot;</TABLE>&quot;
Set objItem = Nothing
Set objFolder = Nothing
Set objFSO = Nothing
%>
<p align=&quot;right&quot;><font face=&quot;Verdana&quot; size=&quot;1&quot;>©2004, Gungor Productions.&nbsp;
All Rights Reserved.</font></p>
</BODY>
</HTML>
 
I have the boxes showing now, but I want to be able to submit to the same asp and have it call a function to delete the files. this is where I am stuck now. Here is the code I have now:

<%@ 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=&quot;center&quot;><b><font size=&quot;5&quot;>Gungor Productions File Exchange Management Interface</font></b></p>
<div style=&quot;border-bottom: #A91905 2px solid;font-size:16&quot;><br><strong>Select files to delete from Server:</strong></div>
<%
Dim strPath 'Path of directory to show
Dim objFSO
Dim objFolder
Dim objItem
strPath=&quot;./files&quot;
Set objFSO = Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set objFolder = objFSO.GetFolder(Server.MapPath(strPath))
response.write &quot;<form method=&quot;&quot;POST&quot;&quot; action=&quot;&quot;manage.asp&quot;&quot; onSubmit=&quot;&quot;return onSubmitForm();&quot;&quot;><TABLE>&quot; &_
&quot;<tr><TD></TD><TD><strong>File Name</td></strong>&quot; &_
&quot;<TD><strong>Size</strong></TD></TR>&quot;
For Each objItem In objFolder.Files
response.write &quot;<tr><TD><input type=&quot;&quot;checkbox&quot;&quot; name=&quot;&quot;&quot; & objItem.Name & &quot;&quot;&quot; value=&quot;&quot;ON&quot;&quot;></TD><TD><A HREF=&quot;&quot;&quot; &_
strPath & objItem.Name &_
&quot;&quot;&quot;>&quot; & objItem.Name & &quot;</A></TD>&quot; &_
&quot;<TD>&quot; & objItem.Size & &quot;</TD></TR>&quot;
Next
response.write &quot;</TABLE><p><input type=&quot;&quot;submit&quot;&quot; value=&quot;&quot;Delete Selected Files&quot;&quot; name=&quot;&quot;B1&quot;&quot;></p></form>&quot;
Set objItem = Nothing
Set objFolder = Nothing
Set objFSO = Nothing
%>
<p align=&quot;right&quot;><font face=&quot;Verdana&quot; size=&quot;1&quot;>©2004, Gungor Productions.&nbsp;
All Rights Reserved.</font></p>
</BODY>
</HTML>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top