WebFileUploader

From Xojo Documentation

Class (inherits from WebControl)

WebFileUploader enables you create a list of files to upload to the server. You can then upload the list of files by calling the Upload method.

Events
Close KeyPressed Resized
ContextualMenuAction LostFocus Shown
DoubleClick MouseDown UploadBegin
DropObject MouseEnter UploadComplete
FileAdded MouseExit UploadError
FileRemove MouseMove UploadProgress
GotFocus MouseUp
Hidden Open
Properties
AlternateRowColor Left Parent fa-lock-32.png
ContextualMenu Limit PrimaryRowColor
ControlID fa-lock-32.png LockBottom Style
Cursor LockHorizontal Top
DragOverStyle LockLeft UploadTimeout
Enabled LockRight VerticalCenter
FileCount fa-lock-32.png LockTop Visible
Filter LockVertical Width
Height MultiSelect Zindex
HelpTag Name fa-lock-32.png
HorizontalCenter Page fa-lock-32.png


Methods
AcceptPictureDrop CancelUpload RemoveFileAtIndex
AcceptRawDataDrop Close SetFocus
AcceptTextDrop ExecuteJavaScript ShowURL
AllowPictureDrag FileAtIndex Upload
AllowRawDataDrag MsgBox
AllowTextDrag PresentContextualMenu

Notes

Files that are larger than 256K are written directly to the temporary folder on the disk. If the temporary folder is not writable or the file is 256K or smaller than the file is kept in memory.

When the UploadeComplete event handler is called, all files in memory are also written to the temporary folder (if it is writable).

Starting with 2018r1, you can drag and drop files onto the WebFileUploader control to add them to the list.

Sample Code

To allow files to be uploaded to your web apps, add a FileUploader control to a web page. By itself, the user uses the "+" and "-" buttons to add or remove files to the list of files to upload. You'll want to add a WebButton to the page for the user to click to start the upload. In the Action event handler for the button, start the upload:

FileUploader1.Upload

After the files have been uploaded, they will be in memory and the UploadComplete event handler is called. Here you can process the uploaded files and choose to do something with them. This code saves uploaded files to disk (you'll need to make sure your web app has the correct permissions on the server in order to write files):

Var outputFile As FolderItem
Var output As BinaryStream
For Each file As WebUploadedFile In files
Try
outputFile = New FolderItem(file.Name)
output = BinaryStream.Create(outputFile, True)
output.Write(file.Data)
output.Close
Catch e As IOException
Continue
End Try
Next

See Also

WebUploadedFile