Haneef Puttur

ASP Script to display folder contents using ASP

ASP Script to Display folder contents.
Note : Keep all folders inside a folder Download
************************************
<%
set FileSysObj=CreateObject(“Scripting.FileSystemObject”)
    strFileAndPath = request.servervariables(“SCRIPT_NAME”)
    strPathOnly = Mid(strFileAndPath,1 ,InStrRev(strFileAndPath, “/”))
‘strPathOnly = Mid(strFileAndPath,1 ,InStrRev(strFileAndPath, “/download/”))
    strFullPath = server.mappath(strPathOnly)&”/download”
If Request.Querystring(“path”)<>“” Then
strFullPath = server.mappath(strPathOnly)&”/download/”&Request.Querystring(“path”)
Else
    strFullPath = server.mappath(strPathOnly)&”/download”
End If
    set fldr=FileSysObj.GetFolder(strFullPath)
response.write ”

    ‘response.write(“

Folders list

“)
    set FolderList = fldr.SubFolders
    For Each FolderIndex in FolderList
        Response.Write(“  ” & Replace(FolderIndex.name,”_”,” “) & “
“)
    Next
   ‘ response.write(“

Files list

“)
   response.write ”
———————-
    set FileList = fldr.Files
    For Each FileIndex in FileList
        ‘This bit excludes this page (and other asp files) from the list of links
        if Lcase(right(FileIndex.Name, 4)) <> “.asp” then
If Request.Querystring(“path”)<>“” Then
            Response.Write(“  ” & Replace(FileIndex.name,”_”,” “) & ” – Click to Download
“)
       Else
Response.Write(“  ” & Replace(FileIndex.name,”_”,” “) & ” – Click to Download
“)
       
End If
 end if
    Next
%>
*********************

.

Exit mobile version