WebUploadedFile sample code uses older Var?

I am curious - are we supposed to be going back to the use of Var?

And I get an error that Files does not exist.

Var saveFile As FolderItem
For Each file As WebUploadedFile In Files
saveFile = SpecialFolder.Documents.Child(file.Name)
Try
file.Save(saveFile)
Catch e As IOException
// File Error, skip file
Continue
End Try
Next

I found this sample code at: Page Not Found — Xojo documentation

Is this code old or new? I am using Xojo 2018r3 - did the Dim disappear in the new release??
I ask this because the code reference said the page “was last edited on 25 August 2019, at 18:04.”

Var can be used instead of Dim in newer versions of Xojo (2019r2 and newer). Dim can also be used, it didn’t disappear just that API 2.0 the use of Var is preferred.

And in the following code, which is in the documentation, Files results in an ERROR of “This item does not exist” - how do I fix this error?

Here is the code as supplied from the user documentation when I click F1 and search for WebUploadedFile:

Dim source As Picture
Dim pictureFile As FolderItem

Dim uploadFolder As FolderItem
uploadFolder = GetFolderItem(“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

dont try and use the code from the wiki in 2018r3
the code on the wiki is for the current version and you’re using an older release
switch your version to use the local help instead and that will give you help that is more consistent with the version you’re using
Preferences > General > When seeking help > Use Built in documentation

I’ve already got it set to that. Thanks for the Wiki tip-off.

So this bit where it mentions “Files” - what exactly is Files? It’s not mentioned in the help documentation as its own entity. It is mentioned in the WebPicture.Constructor as an array but is not mentioned in WebUploadedFile.

This has me … frustrated.

I figured it out. Files() as WebUploadedFile is a parameter that is already declared in the UploadComplete event handler and would have to be declared as incoming parameter in any method I create…

Still trying to get this to work but hey - I stepped forward one baby step.

Found the solution within one of the sample apps.
Yay!

For everyone else…
The corrected code is:

Dim source As Picture
Dim pictureFile As FolderItem

Dim uploadFolder As FolderItem
uploadFolder = GetFolderItem(“UploadFolder”)

If Not uploadFolder.Exists Then
uploadFolder.CreateAsFolder
End If

For i As Integer = 0 To UBound(files)
Try
source = Picture.FromData(files(i).Data)

// Create a file on the server
pictureFile = uploadFolder.Child(files(i).Name )

source.Save(pictureFile, Picture.SaveAsPNG)

Catch e As UnsupportedFormatException
Continue // Skip this file
End Try
Next