webForumDet fria alternativet

lista filer i dropmeny

ASP

2 svar · 294 visningar · startad av Belthor

Medlem sedan okt. 200331 inlägg
Frågan#1

hej, jag har ett script som listar filer i en mapp på servern, nu skulle jag vilja ha det i en dropmeny, men vet inte riktigt hur jag ska skriva for satsen för att få varje fil på egen rad.

Här är scriptet som jag har för att lista filerna:

<%
Function ShowFileList(strPath)
Dim objFS, objFolder, objFile, strFiles
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFS.GetFolder(strPath)
strFiles=""
For Each objFile in objFolder.Files
strFiles = strFiles & objFile.Name & "<br>"
Next
Set objFolder=Nothing
Set objFS=Nothing
ShowFileList=strFiles
End Function

%><select>
<option><%=ShowFileList("c:\download")%></option>
</select

Medlem sedan juni 200032 967 inlägg
#2

Detta borde funka:

<%
Function ShowFileList(strPath)
Dim objFS, objFolder, objFile, strFiles
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFS.GetFolder(strPath)
strFiles=""
For Each objFile in objFolder.Files
strFiles = strFiles & "<option>" & objFile.Name & "</option>"
Next
Set objFolder=Nothing
Set objFS=Nothing
ShowFileList=strFiles
End Function

%><select>
<%=ShowFileList("c:\download")%>
</select>

Och du, använd [kod]-taggar när du postar kod.

Mvh

Medlem sedan okt. 200331 inlägg
#3

Tackar, det funkade utmärkt. (ska skriva i kod taggar nästa gång)

291 ms totalt · 4 externa anrop · v20260731065814-full.86ec41c2
154 ms — deklarationer (db)
0 ms — hämta statistik (cache)
133 ms — hämta tråd, inlägg och bilagor (db)
155 ms — ändringar (db)