Class

WebUploadedFile


Description

A file that was processed by WebFileUploader. The array of uploaded files is made available in the WebFileUploader event handler.

Properties

Name

Type

Read-Only

Shared

Data

MemoryBlock

File

FolderItem

MIMEType

String

Name

String

Size

UInt64

Methods

Name

Parameters

Returns

Shared

Save

Destination As FolderItem

Property descriptions


WebUploadedFile.Data

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.


WebUploadedFile.File

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.


WebUploadedFile.MIMEType

MIMEType As String

The MIME type of the file, such as “application/octet-stream” or “image/png”.


WebUploadedFile.Name

Name As String

Returns the name of the uploaded file.


WebUploadedFile.Size

Size As UInt64

The number of bytes in the file.

Method descriptions


WebUploadedFile.Save

Save(Destination As FolderItem)

Saves the uploaded file out to a permanent location.Internally uses BinaryStream, so this can cause an IOException. Be sure to use a Try/Catch block to handle the IOException in case disk is full.

Notes

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.

Sample code

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

Compatibility

Web projects on all supported operating systems.

See also

Object parent class; WebFileUploader, FolderItem