This feature is called
File Upload [Legacy] for Appway 8 and higher. It has been deprecated in Appway 9 and will be removed in Appway 11 or later. This means that you can currently still use this feature, but should plan to phase it out. For more information on deprecation and on suggested actions, see
Feature Removal and Deprecation with Appway 9.0.
File Upload is a Screen Component that allows to search and upload a file from a local folder.
File Upload properties are:
- Size – Horizontal size of the text field inside the File Upload widget
- Mime-Type Filter – Filter specifying which file types are accepted (examples:
application/pdf, text/*)
- There is no restriction on the size of the file being uploaded.
- If a File Upload component is present on the Screen, the encType property of the HTML Form Screen Component is automatically set to multipart/form-data.
- If a file is selected for upload, a new directory under
$DATA_HOME/work/tmp is created. The content of the file is stored in this directory as file.dat and additional information like content type and original file name is stored in a Java Properties file called file.dat.properties in the same directory. The absolute path to file.dat is stored in the Data Property bound to this Component. - Files within the directory $DATA_HOME/work/tmp are by default automatically deleted if they have not been modified in the last 24 hours.
- In a clustered environment it is necessary to move the file to a shared location (among the nodes). Otherwise, the files can be cleared after 24 hours.
- Use a Script Action to execute additional tasks like reading the file's content or copying it to a different location.
Here is an example for a File Upload component bound to a variable named $uploadedFile. This Script moves the uploaded file to a new location within the file system.
Script
If $uploadedFile != null Then
If FILEEXISTS($uploadedFile) Then
Local Named String $properties;
$properties := READPROPERTIESFILE(JOIN($uploadedFile, '.properties'));
Local String $imagepath;
$imagepath := JOIN('uploadedpictures/', UID(), '_', FILENAME($properties['fileName']));
COPYFILE($uploadedFile, $imagepath);
End
End
The File Upload Style Business Object allows styling the File Upload Screen Component.
The File Upload Style Business Object only displays the Default state.
- Button: refers to a Button Style Business Object. It defines the style of the button you click to upload the file.
- Text: refers to a Text Style Business Object. It defines the style of the no file selected text or, if the file has been selected, the name of the file itself.
For both widgets, if you select the Pass-Through check box, the states specific to the component selected in the Style Id field are passed to the Button and Text component, respectively.
For more information, see the Style Business Object article.