Tak for dit link.. men koderne viser ikke en liste af filer fra en server mappe.. Den viser kun en fil ad gangen. :o/ Jeg venter lige med at give dig de 100 points, hvis nogle skulle komme med flere forslag :) Hvis ikke der er et bedre forslag får du points´ne senere.
Men mange tak for linket.. Jeg kendte ikke den side.. den virker rigtig god..
<% Sub BuildUploadRequest(RequestBin) 'Get the boundary PosBeg = 1 PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13))) boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg) boundaryPos = InstrB(1,RequestBin,boundary) 'Get all data inside the boundaries Do until (boundaryPos=InstrB(RequestBin,boundary & getByteString("--"))) 'Members variable of objects are put in a dictionary object Dim UploadControl Set UploadControl = CreateObject("Scripting.Dictionary") 'Get an object name Pos = InstrB(BoundaryPos,RequestBin,getByteString("Content-Disposition")) Pos = InstrB(Pos,RequestBin,getByteString("name=")) PosBeg = Pos+6 PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34))) Name = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg)) PosFile = InstrB(BoundaryPos,RequestBin,getByteString("filename=")) PosBound = InstrB(PosEnd,RequestBin,boundary) 'Test if object is of file type If PosFile<>0 AND (PosFile<PosBound) Then 'Get Filename, content-type and content of file PosBeg = PosFile + 10 PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34))) FileName = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg)) 'Add filename to dictionary object UploadControl.Add "FileName", FileName Pos = InstrB(PosEnd,RequestBin,getByteString("Content-Type:")) PosBeg = Pos+14 PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13))) 'Add content-type to dictionary object ContentType = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg)) UploadControl.Add "ContentType",ContentType 'Get content of object PosBeg = PosEnd+4 PosEnd = InstrB(PosBeg,RequestBin,boundary)-2 Value = MidB(RequestBin,PosBeg,PosEnd-PosBeg) Else 'Get content of object Pos = InstrB(Pos,RequestBin,getByteString(chr(13))) PosBeg = Pos+4 PosEnd = InstrB(PosBeg,RequestBin,boundary)-2 Value = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg)) End If 'Add content to dictionary object UploadControl.Add "Value" , Value 'Add dictionary object to main dictionary UploadRequest.Add name, UploadControl 'Loop to next object BoundaryPos=InstrB(BoundaryPos+LenB(boundary),RequestBin,boundary) Loop
End Sub
'String to byte string conversion Function getByteString(StringStr) For i = 1 to Len(StringStr) char = Mid(StringStr,i,1) getByteString = getByteString & chrB(AscB(char)) Next End Function
'Byte string to string conversion Function getString(StringBin) getString ="" For intCount = 1 to LenB(StringBin) getString = getString & chr(AscB(MidB(StringBin,intCount,1))) Next End Function
assetFolder = "downloads\"
strHTML = ""
set objFSO = server.CreateObject ("Scripting.FileSystemObject") set objMainFolder = objFSO.GetFolder(server.MapPath(assetFolder))
catid = CStr(request("catid"))
strMappeNavn= catid cutindex = InStrRev(strMappeNavn,"\") if cutindex > 0 then strMappeNavn= Right(strMappeNavn, Len(strMappeNavn)-cutIndex) end if
if catid="" then catid = objMainFolder.path
set objTempFSO = server.CreateObject ("Scripting.FileSystemObject") set objTempFolder = objTempFSO.GetFolder (catid) set objTempFiles = objTempFolder.files
strHTML = strHTML & "<table border=0 cellpadding=3 cellspacing=0 width=240>" for each objTempFile in objTempFiles
on error resume next ContentType =UploadRequest.Item("inpFile").Item("ContentType") FILEFLAG = err.number on error goto 0
if FILEFLAG = 0 then ContentType = UploadRequest.Item("inpFile").Item("ContentType") FilePathName = UploadRequest.Item("inpFile").Item("FileName") FileName = Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\")) Value = UploadRequest.Item("inpFile").Item("Value") else FileName = "" end if
if FileName<>"" then Set objFSO2 = Server.CreateObject("Scripting.FileSystemObject") Set MyFile = objFSO2.CreateTextFile(server.MapPath(".") & "\" & assetFolder & "\" & Request.QueryString("Mappe") & "\" & FileName) MyFile.Write getString(value) MyFile.Close end if
set UploadRequest = nothing
Response.Redirect (Request.ServerVariables("SCRIPT_NAME")) End If %> <html> <head> <title>Filer for nedlastning</title>
WOOW.. Det er lige præcis set jeg har brug for.. og det virker (næsten)..
last opp funktionen virker ikke.. og jeg får en fejl-meddelelse på følgende.
"for each objFolder in objFolders" linie 131..
Jeg roder lidt med koden.. Men det er helt fantastisk.. TAK.. :)
Kivig
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.