Data As MemoryBlock
The contents of the file.
If the file exists on disk, accessing this property loads the file into memory.
If the file does not exist on disk, then this property contains the file data which can be then written out to disk using a BinaryStream.
File As FolderItem
The path of the uploaded file if it exists in the temporary folder.
If the uploaded file exists in the temporary folder, this property contains a reference to it.
MIMEType As String
The MIME type of the file, such as “application/octet-stream” or “image/png”.
Name As String
Returns the name of the uploaded file.
Size As UInt64
The number of bytes in the file.
Save(Destination As FolderItem)
If the temporary folder is writable, the File property will point to the temporary file and the Save method will allow you to save the file elsewhere. You can also use the Data property to load the file into memory.
Any temporary files that are created by the upload process are deleted when the WebFileUploader event handler returns.
If the temporary folder is not writable, the files are kept in memory and accessed using the Data property.
This code in WebFileUploader will process all the files that were uploaded and save only the pictures to the UploadFolder on the server.
Var source As Picture Var pictureFile As FolderItem Var uploadFolder As FolderItem uploadFolder = New FolderItem("UploadFolder") If Not uploadFolder.Exists Then uploadFolder.CreateAsFolder End If For Each file As WebUploadedFile In Files Try source = Picture.FromData(file.Data) // Create a file on the server pictureFile = uploadFolder.Child(file.Name) source.Save(pictureFile, Picture.SaveAsPNG) Catch e As UnsupportedFormatException Continue // Skip this file End Try Next
Web projects on all supported operating systems.