|
|
|
|
|
- Default events
- Event for receiving the files
- Example
WEBDEV manages the following events by default (in order of appearance in the code editor) in the Upload control: | | Event | Runtime condition |
---|
Initializing (Server code) | Executed when the page is opened. * | Whenever the list of selected files is modified (Browser code) | Executed when modifying the list of files to upload. In the case of a single-file Upload control, this event is executed as soon as a file is selected. In the case of a multi-file Upload control, this event is executed as soon as a file is added to the list. | Progress of transfer (Browser code) | Executed when sending the files to the server. This event is called regularly during the upload to update a progress bar, if available.
For more details, see the "Uploading or Downloading a file" unit example provided with WEBDEV. | IncomingData for uploaded files (Server code) | Executed when receiving the files uploaded by the server. ATTENTION If you use predefined Upload fields (single-file or multi-file), the code in this event must be modified to indicate the location where the files are to be copied to the server.The event "Receive files uploaded" is run in AJAX. You can use all the functions supported in AJAX server code. This events makes it possible, once the upload is complete, to update the page without communicating with the server again. | After receiving the uploaded files (Browser code) | Executed when all the files have been uploaded on the server. Allows you to run a browser process when the upload is complete, without communicating with the server again. |
(*) By default, the "Initialization" event of each control is run according to the order in which the controls were created in the page. To modify this runtime order: - On the "Página" tab, in the "Edición" group, expand "Orden de tabulación" and select "Edit".
- In the window that appears, use the arrows on the right to change the order in which the controls are initialized.
Event for receiving the files The event "Receive files uploaded" is used to manage the location of files uploaded on the server. This event is also used to manage the parameters passed by UploadStart. Indeed, UploadStart is used to start the file upload. If the UploadStart function is called with additional parameters, these parameters are passed to the "Receive uploaded files" event at the end of the upload. To retrieve these parameters, a procedure must be declared in this event (via the PROCEDURE statement). This procedure has the following format: PROCEDURE ProcedureName(<Parameter 1> [, ... [, <Parameter N>]]) The "IncomingData" event can also be used to load uploaded images into a memo section of an HFSQL data file, via the HLinkMemo function. The event "Receive files uploaded" is run in AJAX. You can use all the functions supported in AJAX server code. Code sample used in the "Receive files uploaded" event: // Insert the code for processing uploaded files // Code sample: // Copies the uploaded file into a specific directory // UploadCopyFile(MySelf, sDestinationDirectory, "") // Process each file to upload FOR subscript = 1 TO NbFilesToUpload Trace(UploadFileName(UPL_Upload, False, subscript)) Trace(UploadFileName(UPL_Upload, True, subscript)) UploadCopyFile(UPL_Upload, "c:\temp2", "", subscript) END
Example code for loading images uploaded from a multi-file Upload control in a memo section. // For each uploaded image FOR I = 1 _TO_ UPL_UploadControl.Occurrence // Add into the database HReset(Photo) ScreenToFile() // UploadFileName(UPL_UploadControl, True, i): // is used to retrieve the path of the nth file uploaded on the server // This file is a temporary file created on the server // This file is automatically deleted at the end of the event // "Receiving the uploaded files" HLinkMemo(Photo, Image, UploadFileName(UPL_UploadControl, True, I)) HAdd(Photo) END
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|