File

File control for uploading a single client-side file. See File Upload Area for multiple files.

When used in conjunction with NewEdit, additional control names are also returned. If the file control ID is Xyz then the parameters @XyzFileName, @XyzContentType, and @XyzContentSize are also posted. (ContentSize is only returned for legacy reasons and you can safely ignore its value. If you need to determine the length of your data then use the DATALENGTH function.)

CREATE PROCEDURE xxx_InsertUpdate
  ...
  @Xyz varbinary(max),
  @XyzFileName nvarchar(300),
  @XyzContentType varchar(300),
  @XyzContentSize int
AS
...

To display an existing file, use SoftadminApi.FileControl_CreateExistingFileToken. If the user has not changed the file when saving, an additional parameter @XyzFileId will be passed to the procedure containing the given file id.

It is possible to specify which file extensions the user can select from and the maximum file size allowed by creating an input validation using the File category.

Start value: Binary data generated by SoftadminApi.FileControl_CreateExistingFileToken.
Return value: Selected file from local/network hard drive.
Supported in: NewEdit

Appearance

alt text
The "Choose File" button opens a standard file dialog where the user can select a file to upload.

Best practice

GetEditFields

Use SoftadminApi.FileControl_CreateExistingFileToken in GetEditFields if you want to display an existing file. Otherwise use CONVERT(varbinary(MAX), NULL) in instead of returning file data which will be discarded anyway.