File.Upload(Text, Text, Text, Text, var Text) Method

Version: Available or changed with runtime version 1.0.

Sends a file from the client computer to the server computer. The client computer is the computer that is running the Windows client or the computer that is running a browser that accesses the web client.

Note

This method is supported only in Business Central on-premises.

Syntax

[Ok := ]  File.Upload(DialogTitle: Text, FromFolder: Text, FromFilter: Text, FromFile: Text, var ToFile: Text)

Note

This method can be invoked without specifying the data type name.

Parameters

DialogTitle
 Type: Text
The title that you want to display in the dialog box for uploading the file. This parameter is not supported by the web client. The title is determined by the end-user's browser.

FromFolder
 Type: Text
The name of the folder that is displayed in the dialog box. This is the default value, and the user can change it. This parameter is not supported by the web client. The browser uses the folder that was last accessed.

FromFilter
 Type: Text
The type of file that can be uploaded to the server. In the Windows client, the type is displayed in the upload dialog box, so that the user can only select files of the specified type. For the web client, a user can try to upload any file type but an error occurs if the file is not the specified type.

FromFile
 Type: Text
The default file that you want to upload to the service. The name displays in the dialog box for uploading the file. The user can change the file. This parameter is not supported by the web client.

ToFile
 Type: Text
The path and file name to give the uploaded file. If you do not provide a path, or you upload the file that uses web client, then the file is uploaded to the following folder on the computer that is running the server: \ProgramData\Microsoft\Microsoft Dynamics NAV\110\Server\MicrosoftDynamicsNAVServer$DynamicsNAV110\users\ServiceAccount

Return Value

[Optional] Ok
 Type: Boolean
true if the operation was successful; otherwise false. If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.

Remarks

Note

This method is not supported on devices that run Apple iOS, such as iPad. The dialog box for uploading a file displays, but it is disabled and the user cannot select a file.

The business logic is run on the Dynamics 365 Business Central service and not on the client. Files are created on the Dynamics 365 Business Central service and not locally on the client.

Upload Method (File) and UploadIntoStream Method (File) are used to send a file from the client to a Dynamics 365 Business Central service.

Download Method (File) and DownloadFromStream Method (File) are used to send a file from a Dynamics 365 Business Central service to the client.

We recommend that you use the methods in codeunit 419, File Management, to upload and download files.

Example

The FromFilter parameter must follow this pattern: <ExtensionGroupName>|<extension1>;<extension2>, for example 'Word files|*.docx;*.doc'.

This example uses a text file:

Upload('Upload file','C:\','Text file (*.txt)|*.txt','Test.txt',varTest);  

See Also

File Data Type
Get Started with AL
Developing Extensions