UploadFiles
Use to open the Upload Files dialog box that enables an application user to upload files from the local computer to the Web server.
Syntax
1 |
void <span>UploadFiles</span> (string <var>serverFolder</var>, long <var>bgColor</var>, int <var>fileNum</var>, boolean <var>showServerFolder</var>, string <var>description</var>, string <var>allowExts</var>{, string <var>callbackFunctionName</var>}{, PowerObject <var>po</var>}) |
Parameters
-
serverFolder �
The folder on the server to which you want to copy one or more files from the client computer. PowerBuilder creates this folder under the server virtual root in the applicationName_rootsessionsessionID directory, or for someone logged in as a permanent user, in the applicationName_rootusersuserName directory. -
bgColor �
A long for the background color of the Upload Files dialog box. -
fileNum �
An integer for the number of text boxes to show in the Upload Files dialog boxes. Application users can upload as many files as there are text boxes in a single upload operation. -
showServerFolder �
A boolean specifying whether to show the server folder name in the Upload Files dialog box. Values are:
- true � the server folder name.
- false � do not show the server folder name.
-
description �
Text that you want to appear near the top of the Upload Files dialog box. You can use an empty string if you do not want to show additional text in this dialog box. -
allowExts �
A string that lets you limit the files a user can upload to files with the extensions you list. If you set this argument to an empty string, files with any file extension can be uploaded. If you list multiple extensions, you must separate each extension with a semicolon. You must include the “.” (dot) in the extensions you list. -
callbackFunctionName �
(Optional) The callback function that lets you know whether the file is correctly uploaded to the Web server. -
po �
(Optional) The name of a PowerBuilder object that has the callback function set in the callbackFunctionName argument.
Returns
None.
Examples
-
�
This example uploads the file to the application�s virtual root d:hhh directory on the server, sets the color of the Upload Files dialog box to the background color of the w_main application window, limits the number of files to be uploaded in a single operation to 3, does not show the server directory name in the Upload Files dialog box, but does show the “my description” text, and limits the types of files that can be uploaded to JPG and TXT files:
12345#if defined PBWEBFORM thenUploadFiles("d:hhh", w_main.BackColor, 3, false,"my description", ".jpg;.txt","myuploadfiles_callback", w_main)#end if -
�
This example uses green as the background color for the Upload Files dialog box, limits the number of files to be uploaded in a single operation to 1, shows the server folder name in the Upload Files dialog box, and does not restrict the types of files a user can upload to the Web server:1234#if defined PBWEBFORM thenUploadFiles("c:hhh", RGB(0, 255, 0), 1, true, "", "","myuploadfiles_callback", w_main)#end if
Usage
Use the UploadFiles function in conjunction with a private callback function that you create for a PowerBuilder object.
1 2 3 4 5 |
int i for i = 1 to upperbound(up_files) this.mle_1.text += "~r~n" + up_files[i] next return i |
If the “myuploadfiles_callback” function is created on the window w_main, you can use this window name as the value of the po argument in your Upload Files call. If you create the “myuploadfiles_callback” function as a global function, you can use the UploadFiles callback syntax without the po argument.
If your application uses sequential UploadFiles calls in the same script, only the callback function in the last of the UploadFiles calls is valid. The other UploadFiles calls can still upload selected files to the Web server, but further processing of the names of the uploaded files does not occur, even when the syntax for these calls includes a callback function that codes for such processing.
If the last UploadFiles call in a script containing sequential UploadFiles calls does not use a callback function, no callback processing occurs.