AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Ayuda / WLanguage / Funciones WLanguage / Funciones específicas de la Web / Funciones de carga de archivos (Upload)
  • Overview
  • Available elements
  • Remark
  • Maximum size of files to upload
  • Uploading files with an Upload control (legacy option)
  • Uploading a file in a page
  • Displaying the image to upload
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Overview
Uploading consists in saving a file located on the user's computer to a web server. The file from the user's computer is uploaded to the server.
All types of files can be uploaded.
File upload examples:
  • Address book site: When users add a new contact to the directory, they can select the contact's photo from their device. The image is uploaded to the server, so that the same image is displayed to all users.
  • Documentation site: Each user can share various types of documents with others. These documents are selected on the user's computer and uploaded to the server so that they can be viewed by all the other users.
Available elements
The following elements are used to manage the file upload:
  • Single-file or multi-file Upload control: Several ready-to-use controls are automatically inserted in the editor. This control can be generated for HTML5-based websites. For more details, see Upload control.
  • an Upload Edit control: In the browser, a "Browse" button is automatically added to the right of the Upload Edit control.. This button allows the Web user to select the file to "upload".
    A gray button is displayed in the editor. This button cannot be modified (style, caption, ...).
    Warning
    This type of Edit control is kept for compatibility.
    Caution:
    • This Edit control is a specific control. It is not recommended to use Value properties on it..
    • To get the name of the uploaded file, use UploadFileName.
    The upload mode with this type of control is presented in Upload via an edit control.
  • two server functions of WLanguage:
    UploadCopyFileSaves an "uploaded" file on the server. During this backup, the saved file can be renamed on the server.
    UploadFileNameReturns the name of an "uploaded" file (initial file name or file name saved on server)
  • several WLanguage functions allow you to handle Upload controls on the browser side:
    UploadCurrentFileIndicates the file currently uploaded via the Upload control.
    UploadCurrentFileSizeReturns the total size (in bytes) of the file currently uploaded via an Upload control.
    UploadCurrentFileSizeSentReturns the size (in bytes) already sent for the file currently uploaded via an Upload control.
    UploadDeleteDeletes a file from the list of files to upload: the file will not be uploaded on the server.
    UploadDeleteAllClears the list of files to upload: no file will be uploaded on the server.
    UploadSizeReturns the total size (in bytes) of the file currently uploaded via an Upload control.
    UploadSizeSentReturns the total size (in bytes) of files already sent by the current upload via an Upload control.
    UploadStartStarts sending the selected files into an Upload control.
Remark

Maximum size of files to upload

By default, the size of files to upload is not limited in the WEBDEV engine. This size can be limited:
  • by the Web server used. For more details, see the documentation about the Web server used.
  • by WEBDEV Application Server.
The file will not be uploaded if its size exceeds the limit size.
To modify the maximum size of files to upload in WEBDEV Application Server, the registry must be modified on the server. This modification can be performed for all the WEBDEV applications.
To modify the size of the uploaded files for all the WEBDEV applications:
  1. Select the following registry key:
    • On a 64-bit computer: HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\PC SOFT\WEBDEV\30.0
    • On a 32-bit computer: HKEY_LOCAL_MACHINE\SOFTWARE\PC SOFT\WEBDEV\30.0
  2. Add the MAX_UPLOAD key. The value of this key corresponds to the maximum size of files to upload (in KB).
For a large transfer (several hundreds of MB), we recommend that you use the FTP protocol instead of the upload. You have the ability to perform an FTP transfer from a WEBDEV page, via a Java applet created with WINDEV.
PHP Limits in PHP:
  • The size of the uploaded files is limited by the "upload_max_filesize" and "post_max_size" directives in the configuration file of PHP (php.ini file).
  • The file upload must be allowed by the PHP server. To do so, the "file_uploads" directive must be set to "on" in the configuration file of PHP (php.ini file).
  • The upload_tmp_dir directive of the configuration file must be specified toward a directory with read/write rights.
Uploading files with an Upload control (legacy option)

Uploading a file in a page

To upload a file in a page:
  1. Create an Upload Edit control (the type of the control is defined in the "General" tab of the control). This control allows the Web user to select the file to "upload".
  2. Add a Button control or a Link control. This control will be used to upload the file on the server. This Button or Link control must be of type "Submit" ("Button action" in the "General" tab of the control description window). When the page is validated using this control, the file is uploaded to a temporary directory on the server. Therefore, this file cannot be viewed by the other Web users.
  3. In the server click code of this Button or Link control, you can use:
    • UploadFileName (UploadFileName(<Upload control>, False)) to check whether the file was uploaded and to retrieve its name. Indeed, during the upload, the file is renamed with a temporary file name.
    • UploadCopyFile to copy and rename the uploaded file on the server. You can copy this file to the resource directory (_WEB) or to a directory accessible via an alias.
    • HLinkMemo to load the image in a memo item of an HFSQL data file.
Caution: In the code, do not use file names directly (e.g., reading the value with the Value property in server or browser code). This approach works during the development phase, as the server and the browser are on the same computer, but not in production. In this case, the server and the browser are different computers. Browser files are unknown to the server. To get the names of the files to use, use UploadFileName.

Displaying the image to upload

To display the image previously selected with an Upload edit control (EDT_UploadControl) in an Image control (IMG_ImageControl):
  1. In the code of the page, add the optional "OnMouseMove" browser code.
  2. Enter the following lines of code in this code:
    IF EDT_UploadControl <> "" THEN
    	IF IMG_ImageControl <> EDT_UploadControl THEN
    		IMG_ImageControl = EDT_UploadControl
    	END
    END
Note: This may not work depending on the browser and security level.
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
Versión mínima requerida
  • Versión 9
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 23/01/2025

Señalar un error o enviar una sugerencia | Ayuda local