Theo_Rie
July 19th, 2001, 09:04 AM
Hi there!
I'm trying to put up a small download-area (Pw protected) on my Internet Server. I already found a way to upload (using aspsmartupload) and i now can display the files uploaded in the folder like that:
File Name Size Date
Presentation.ppt 12330 07/19/01
Resellers.doc 54008 07/18/01
...
Code extract:
-----
<body>
<%
Dim strPathInfo, strPhysicalPath, linkText1, linkText2
'strPathInfo = Request.ServerVariables("SCRIPT_NAME")
strPathInfo = "/site/content/associates/filetransfer/etc/download/!dummy.txt"
strPhysicalPath = Server.MapPath(strPathInfo)
dim objFSO, objFile, objFileItem, objFolder, objFolderContents
set objFSO = CreateObject("Scripting.FileSystemObject")
'response.write(strPathInfo)
'response.write("<BR>")
'response.write(strPhysicalPath)
'response.write("<BR>")
'response.write(Request.ServerVariables("PATH_TRANSLATED"))
'if you have a virtual folder set up you need to use the next line, not the second line below
set objFile = objFSO.GetFile(strPhysicalPath)
'set objFile = objFSO.GetFile(Request.ServerVariables("PATH_TRANSLATED"))
set objFolder = objFile.ParentFolder
set objFolderContents = objFolder.Files
%>
<table cellpadding=5>
<tr align=center>
<th align=left >Filename</th>
<th align=right >Size</th>
<th align=right >Date</th>
</tr>
<%
For Each objFileItem In objFolderContents
Response.write("<tr><td align=left>")
linkText1 = "../etc/download/" & objFileItem.Name
linkText2 = objFileItem.Name
'Response.write(linkText1)
if linkText2 <> "!dummy.txt" then
%>
<a href=<%=linkText1%>><%=linkText2%></a>
<%
Response.write("</td><td align=right>")
Response.write(objFileItem.Size)
Response.write("</td><td align=right>")
Response.write(objFileItem.DateLastModified)
Response.write("</td></tr>")
end if
Next
%>
</table>
</body>
<%
set objFSO = nothing
set objFile = nothing
set objFileItem = nothing
set objFolder = nothing
set objFolderContents = nothing
%>
</html>
-----
I am now looking for a way to delete certain files from this folder like this:
File Name Size Date
Presentation.ppt 12330 07/19/01 |x|
Resellers.doc 54008 07/18/01 |x|
The |x| means a button, checkbox,... whatever...
1. If the button is clicked a dialog should apear (Are you sure you want to delete the file 'Presentation.ppt' ? Yes / No
2. If Yes is clicked the file should be deleted and the page refreshed.
If No is clicked then nothing should happen.
How can i do this ?
Thanx a lot for your help!
I'm trying to put up a small download-area (Pw protected) on my Internet Server. I already found a way to upload (using aspsmartupload) and i now can display the files uploaded in the folder like that:
File Name Size Date
Presentation.ppt 12330 07/19/01
Resellers.doc 54008 07/18/01
...
Code extract:
-----
<body>
<%
Dim strPathInfo, strPhysicalPath, linkText1, linkText2
'strPathInfo = Request.ServerVariables("SCRIPT_NAME")
strPathInfo = "/site/content/associates/filetransfer/etc/download/!dummy.txt"
strPhysicalPath = Server.MapPath(strPathInfo)
dim objFSO, objFile, objFileItem, objFolder, objFolderContents
set objFSO = CreateObject("Scripting.FileSystemObject")
'response.write(strPathInfo)
'response.write("<BR>")
'response.write(strPhysicalPath)
'response.write("<BR>")
'response.write(Request.ServerVariables("PATH_TRANSLATED"))
'if you have a virtual folder set up you need to use the next line, not the second line below
set objFile = objFSO.GetFile(strPhysicalPath)
'set objFile = objFSO.GetFile(Request.ServerVariables("PATH_TRANSLATED"))
set objFolder = objFile.ParentFolder
set objFolderContents = objFolder.Files
%>
<table cellpadding=5>
<tr align=center>
<th align=left >Filename</th>
<th align=right >Size</th>
<th align=right >Date</th>
</tr>
<%
For Each objFileItem In objFolderContents
Response.write("<tr><td align=left>")
linkText1 = "../etc/download/" & objFileItem.Name
linkText2 = objFileItem.Name
'Response.write(linkText1)
if linkText2 <> "!dummy.txt" then
%>
<a href=<%=linkText1%>><%=linkText2%></a>
<%
Response.write("</td><td align=right>")
Response.write(objFileItem.Size)
Response.write("</td><td align=right>")
Response.write(objFileItem.DateLastModified)
Response.write("</td></tr>")
end if
Next
%>
</table>
</body>
<%
set objFSO = nothing
set objFile = nothing
set objFileItem = nothing
set objFolder = nothing
set objFolderContents = nothing
%>
</html>
-----
I am now looking for a way to delete certain files from this folder like this:
File Name Size Date
Presentation.ppt 12330 07/19/01 |x|
Resellers.doc 54008 07/18/01 |x|
The |x| means a button, checkbox,... whatever...
1. If the button is clicked a dialog should apear (Are you sure you want to delete the file 'Presentation.ppt' ? Yes / No
2. If Yes is clicked the file should be deleted and the page refreshed.
If No is clicked then nothing should happen.
How can i do this ?
Thanx a lot for your help!