ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Developing an application or website / Controls, windows and pages / Controls: Available types / Upload control
  • Default events
  • Event for receiving the files
  • Example
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
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)
Run when modifying the list of files to upload.
For a single-file Upload control, this event is run when a file is selected.
For a multi-file Upload control, this event is run when a file is added to the list.
Progress of transfer
(Browser code)
Run 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.
Receiving the uploaded files
(Server code)
Run when receiving the files uploaded by the server.
CAUTION: If you use the preset Upload controls (single-file or multi-file), the code in this event must be modified to specify the server location where the files must be copied.
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)
Run 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 change this order of execution:
  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 UploadStart is called with additional parameters, these parameters are transmitted to the "Receive files uploaded" event at the end of 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 event "Receive files uploaded" can also be used to load the uploaded images into a memo item of an HFSQL file, via HLinkMemo.
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 sample used to load the images uploaded from a multi-file Upload control in a memo item.
// 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: 06/22/2023

Send a report | Local help