I need my clients to be able to download multiple files from the server simply. Seems that I should be able to have a download button which allows the user to select the desired folder and then have the files downloaded into the folder in one step.
Most of the answers I’ve seen to this question all recommend zipping the files on the fly so there is just one file to download (the user will still need to unzip it though), or through the use of popup windows/frames/meta refresh to start the individual transfers, but the user will still be prompted for each download (or not, depending on their browser settings)
I have this in the action event of a button. lstFiles is a container emulating a Listbox with a checkbox on each row.
[code] ReDim DownloadFile(-1)
DownloadIndex = -1
Dim f As FolderItem = GetFolderItem(“C:”).Child(“cloud”).Child(Session.User.Field(“client_id”).StringValue).Child(“to”)
For i As Integer = 0 To lstFiles.Checked.UBound
If lstFiles.Checked(i) Then
DownloadFile.Append New WebFile
Dim Index As Integer = DownloadFile.Ubound
DownloadFile(Index).UseCompression = False
DownloadFile(Index) = WebFile.Open(f.Child(lstFiles.Files(i)), false)
DownloadFile(Index).ForceDownload = True
AddHandler DownloadFile(Index).Downloaded, AddressOf DownloadComplete
log(Session.User.Field("email").StringValue, "Downloaded file " + f.Name)
End If
Next i
If DownloadFile.Ubound > -1 Then
If DownloadIndex < 0 Then
DownloadIndex = 0
Call DownloadFile(DownloadIndex).Download
End If
End If[/code]
DownloadFile is a WebFile array property on the page.
My DownloadComplete code is:
Sub DownloadComplete(File As WebFile)
#pragma Unused File
DownloadIndex = DownloadIndex + 1
If DownloadIndex > DownloadFile.Ubound Then
DownloadIndex = -1
Else
Call DownloadFile(DownloadIndex).Download
End If
End Sub
This downloads file after file until complete.
It would appear that pasting code doesn’t take into account long lines, so you can’t just copy & paste, but you’ll get the idea.