Difference between revisions of "WebUploadedFile"

From Xojo Documentation

 
Line 1: Line 1:
{{SupportedPlatforms | type=w}}
 
 
{{ClassBox
 
{{ClassBox
 
| super=[[Object]]
 
| super=[[Object]]
Line 5: Line 4:
 
}}
 
}}
 
{{Description
 
{{Description
|text = A file that was processed by [[WebFileUploader]]. The array of uploaded files is made available in [[WebFileUploader.UploadComplete]]. }}
+
|text = A file that was processed by [[WebFileUploader]]. The array of uploaded files is made available in the [[WebFileUploader.UploadFinished]] event handler. }}
  
 
<dynamicTable id="Properties" class="propertyTable" title="Properties" columns="3">
 
<dynamicTable id="Properties" class="propertyTable" title="Properties" columns="3">
{{Property | name=Data | type=WebMemoryBlock | platform=All | readonly = yes | newinversion=2010r5| description=(String)&nbsp;&nbsp;The contents of the file. }}
+
{{Property | name=Data | description=(MemoryBlock)&#x0A;The contents of the file. }}
{{Property | name=MIMEType | type=String | platform=all | readonly = yes | newinversion=2010r5| description=(String)&nbsp;&nbsp;The MIME type of the file, such as application/octet-stream or image/png. }}
+
{{Property | name=File | description=(FolderItem)&#x0A;The actual file on disk. }}
{{Property | name = Name | type = String | readonly = yes | description = (String)&nbsp;&nbsp;Returns the name of the uploaded file.}}
+
{{Property | name=MIMEType | description=(String)&#x0A;The MIME type of the file, such as application/octet-stream or image/png. }}
{{Property | name=Size | type=UInt64 | platform=All | readonly = yes | newinversion=2010r5 | description=(UInt64)&nbsp;&nbsp;The number of bytes in the file. }}
+
{{Property | name = Name | description = (String)&#x0A;Returns the name of the uploaded file.}}
{{Property | name=File | type=FolderItem | platform=All | readonly = yes | newinversion=2013r3 | description=(FolderItem)&nbsp;&nbsp;The actual file on disk. }}
+
{{Property | name=Size | description=(UInt64)&#x0A;The number of bytes in the file. }}
 
</dynamicTable>
 
</dynamicTable>
  
 
<dynamicTable id="Methods" class="methodTable" title="Methods" columns="3">
 
<dynamicTable id="Methods" class="methodTable" title="Methods" columns="3">
{{Method | name=Save | newinversion=2013r3 | description=Save(Destination As FolderItem) &#x0A;Saves the file in the temporary folder to a new destination. }}
+
{{Method | name=Save | description=Save(Destination As FolderItem)&#x0A;Saves the file in the temporary folder to a new destination. }}
 
</dynamicTable>
 
</dynamicTable>
  
Line 22: Line 21:
 
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.
 
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.UploadComplete]] event handler returns.
+
Any temporary files that are created by the upload process are deleted when the [[WebFileUploader.UploadFinished]] event handler returns.
  
 
If the temporary folder is not writable, the files are kept in memory and accessed using the Data property.
 
If the temporary folder is not writable, the files are kept in memory and accessed using the Data property.
  
 
== Sample Code ==
 
== Sample Code ==
This code in [[WebFileUploader.UploadComplete]] will process all the files that were uploaded and save only the pictures to the UploadFolder on the server.
+
This code in [[WebFileUploader.UploadFinished]] will process all the files that were uploaded and save only the pictures to the UploadFolder on the server.
 
<rbcode>
 
<rbcode>
 
Var source As Picture
 
Var source As Picture

Latest revision as of 20:33, 23 May 2020

Class (inherits from Object)

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

Properties
Data MIMEType Size
File Name
Methods
Save

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.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.UploadFinished 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

See Also

WebFileUploader, FolderItem