Class

# WebUploadedFile

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

A file that was processed by `WebFileUploader</api/user_interface/web/webfileuploader>`. The array of uploaded files is made available in the `WebFileUploader<webfileuploader.uploadfinished>` event handler.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                 | Type                                              | Read-Only | Shared |
|--------------------------------------|---------------------------------------------------|-----------|--------|
| `Data<webuploadedfile.data>`         | `MemoryBlock</api/language/memoryblock>`          |           |        |
| `File<webuploadedfile.file>`         | `FolderItem</api/files/folderitem>`               |           |        |
| `MIMEType<webuploadedfile.mimetype>` | `String</api/data_types/string>`                  |           |        |
| `Name<webuploadedfile.name>`         | `String</api/data_types/string>`                  |           |        |
| `Size<webuploadedfile.size>`         | `UInt64</api/data_types/additional_types/uint64>` |           |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                         | Parameters                                         | Returns | Shared |
|------------------------------|----------------------------------------------------|---------|--------|
| `Save<webuploadedfile.save>` | destination As `FolderItem</api/files/folderitem>` |         |        |

## Property descriptions

<div id="webuploadedfile.data">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebUploadedFile.Data

**Data** As `MemoryBlock</api/language/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</api/files/binarystream>`.

<div id="webuploadedfile.file">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebUploadedFile.File

**File** As `FolderItem</api/files/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.

<div id="webuploadedfile.mimetype">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebUploadedFile.MIMEType

**MIMEType** As `String</api/data_types/string>`

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

<div id="webuploadedfile.name">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebUploadedFile.Name

**Name** As `String</api/data_types/string>`

> Returns the name of the uploaded file.

<div id="webuploadedfile.size">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebUploadedFile.Size

**Size** As `UInt64</api/data_types/additional_types/uint64>`

> The number of bytes in the file.

## Method descriptions

<div id="webuploadedfile.save">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebUploadedFile.Save

**Save**(destination As `FolderItem</api/files/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</api/language/try>` block to handle the `IOException</api/exceptions/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<webfileuploader.uploadfinished>` 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<webfileuploader.uploadfinished>` will process all the files that were uploaded and save only the pictures to the UploadFolder on the server.

``` xojo
Var source As Picture
Var pictureFile As FolderItem

Var uploadFolder As FolderItem = New FolderItem("UploadFolder", FolderItem.PathModes.Native)

If Not uploadFolder.Exists Then
  uploadFolder.CreateFolder
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

|                       |     |
|-----------------------|-----|
| **Project Types**     | Web |
| **Operating Systems** | All |

<div class="seealso">

`Object</api/data_types/additional_types/object>` parent class; `WebFileUploader</api/user_interface/web/webfileuploader>`, `FolderItem</api/files/folderitem>`

</div>
