Opens the Upload Files dialog box that enables an application user to upload files from the local machine to the Web server.
void UploadFiles (string serverFolder, long bgColor, int fileNum, boolean showServerFolder, string description, string allowExts {, string callbackFunctionName}{, PowerObject po })
Argument |
Description |
---|---|
serverFolder |
The folder on the server that contains the file or files you want to copy to the client. |
bgColor |
A long for the background color of the Upload Files dialog box. |
fileNum |
An integer for the number of text boxes to display 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 display the server folder name in the Upload Files dialog box. Values are: |
description |
Text that you want to display near the top of the Upload Files dialog box. You can use an empty string if you do not want to display 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. |
None.
You can use the UploadFiles function in conjunction with a private callback function that you create for a PowerBuilder object.
The callback function should return an integer and take a string array for its only argument. The callback function script should include an iteration to fill up the string array with the names of files selected by the application user to upload to the server. For example, the following code can be added to a callback function “myuploadfiles_callback” with an upfiles[ ] string array argument:
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.
The following 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 display the server directory name in the Upload Files dialog box but does display the “my description” text, and limits the types of files that can be uploaded to JPG and TXT files:
#if defined PBWEBFORM then
UploadFiles("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, displays 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:
#if defined PBWEBFORM then
UploadFiles("c:\hhh", RGB(0, 255, 0), 1, true, "", "", "myuploadfiles_callback", w_main)
#end if