From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

Class (inherits from WebControl)

WebFileUploader allows the user to choose files to be uploaded. You can then upload the files by calling the StartUpload method.

Closed Hidden UploadError
ContextualMenuSelected Opening UploadFinished
FileAdded Shown UploadProgressed
FileRemoved UploadAborted UploadStarted
Caption LockHorizontal fa-lock-32.png Style
ContextualMenu LockLeft fa-lock-32.png TabIndex
ControlID fa-lock-32.png LockRight fa-lock-32.png Tooltip
Enabled LockVertical fa-lock-32.png Top
Filter MaximumBytes UploadTimeout
Height MaximumFileCount Visible
Indicator Name fa-lock-32.png Width
Left Page fa-lock-32.png
LockBottom fa-lock-32.png Parent fa-lock-32.png

CancelUpload GotoURL StartUpload
Close RemoveAllFiles UpdateBrowser
ExecuteJavaScript SetFocus


There will be a delay between the time files finish uploading and the UploadFinished event is called because the files must be processed once they are uploaded.

WebFileUploader will always try to write files to the temporary folder on the server if possible to save memory. If that is not possible (because the temporary folder doesn't exist or is not writable), the files are copied into a MemoryBlock.

Sample Code

To allow files to be uploaded by your web apps, add a FileUploader control to a web page. By itself, the user uses the Select button choose a file to be uploaded. Each time the user chooses a file, that file is added to the upload queue. If you wish to show the user a list of files they have chosen, add a WebListBox to the layout and then add files to that control when the FileAdded event handler is called. You'll likely also want to add a WebButton to the page for the user to click to start the upload. In it's Pressed event handler, call StartUpload:


After the files have been uploaded, they will be in memory and the UploadFinished 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
outputFile = New FolderItem(file.Name)
output = BinaryStream.Create(outputFile, True)
Catch e As IOException
End Try

See Also