ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / Developing an application or website / Controls, windows and pages / Controls: Available types / Upload control
  • Default events
  • Event for receiving the files
  • Example
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Default events
WEBDEV manages the following events by default (in order of appearance in the code editor) in the Upload control:
EventRuntime 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:
  1. On the "Page" tab, in the "Edit" group, expand "Tab order" and select "Edit".
  2. 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
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
Related Examples:
Uploading or Downloading a file Unit examples (WEBDEV): Uploading or Downloading a file
[ + ] This example explains how to upload (copy to the server) or download (download from the server) a file and it allows you to:
- Copy a file from the browser computer to the server
- Download a file found on the server
- Download a file found on the server via a link
- Download a file found on the server by requesting its opening
Minimum version required
  • Version 15
Comments
Click [Add] to post a comment

Last update: 11/15/2024

Send a report | Local help