PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Overview
  • Available elements
  • Upload via an Upload edit control
  • Uploading a file in a page
  • Displaying the image to upload
  • Note
  • Maximum size of files to upload
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Overview
The upload consists in saving on the Web server a file accessible from the computer of the Web user. The file found on the computer of the Web user is "uploaded" to the server: it is loaded and saved on the server.
All types of files can be uploaded.
Examples for using the file upload:
  • Phone Book site: when a new contact is added to the phone book, the Web user can select the contact photo on his computer. In order for the photo to be displayed independently of the Web user, the photo is "uploaded" to the server.
  • Site for document management: each Web user can make different types of documents available to the other Web users: text, ... These documents are selected on the computer of the Web user and "uploaded" to the server in order to be made available to all the Web users.
Available elements
The following elements are used to manage the file upload:
  • 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, ...).
    Caution: this edit control is a specific control: no Value properties should be used on this control. To find out the name of the uploaded file, you must use UploadFileName. The operating mode of upload with this type of control is presented in Upload via an edit control.
  • Versions 15 and later
    an Upload control (single-file or multi-file): Depending on the type of control, several controls are automatically inserted into the editor, with the WLanguage code required to use them immediately. See Upload control for more details.
    New in version 15
    an Upload control (single-file or multi-file): Depending on the type of control, several controls are automatically inserted into the editor, with the WLanguage code required to use them immediately. See Upload control for more details.
    an Upload control (single-file or multi-file): Depending on the type of control, several controls are automatically inserted into the editor, with the WLanguage code required to use them immediately. See Upload control for more details.
    Versions 22 and later
    an Upload control (single-file or multi-file): Several controls are automatically inserted into the editor as well as the WLanguage code required to use them immediately. This control can be generated for an execution based on Flash or on HTML5. See Upload control for more details.
    New in version 22
    an Upload control (single-file or multi-file): Several controls are automatically inserted into the editor as well as the WLanguage code required to use them immediately. This control can be generated for an execution based on Flash or on HTML5. See Upload control for more details.
    an Upload control (single-file or multi-file): Several controls are automatically inserted into the editor as well as the WLanguage code required to use them immediately. This control can be generated for an execution based on Flash or on HTML5. See Upload control for more details.
  • 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)
  • Versions 15 and later
    several WLanguage browser functions are used to handle the Upload control:
    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.
    New in version 15
    several WLanguage browser functions are used to handle the Upload control:
    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.
    several WLanguage browser functions are used to handle the Upload control:
    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.
Upload via an Upload edit control

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 or a link. This control will be used to upload the file on the server. The type of this button or link must be "Submit". When the page is validated via this button, the file is uploaded into a temporary directory of the server. Therefore, this file cannot be viewed by the other Web users.
  3. In the server click code of this button or link, 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. This file can be copied into the resource directory (_WEB) or into a directory accessible via an alias.
    • HLinkMemo to load the image in a memo item of a HFSQL file.
Caution: Using the file name directly on the browser computer (value read by ..Value in server or browser code) in the functions for file management is a HUGE error. Indeed, this operation operates in development mode (the server and the browser are found on the same computer) but NOT in deployment. In this case, the server and the browser are different computers. The server does not see the browser files. To find out the names of the files to use, call UploadFileName.

Displaying the image to upload

To display the image selected in an Upload edit control (EDT_UploadControl) in an Image control (IMG_ImageControl):
  1. In the description window of the Image control ("General" tab), uncheck "Locate the image in the _WEB directory in browser code".In the description window of the Image control ("Details" tab), uncheck "Locate the image in the _WEB directory in browser code".
  2. In the code of the page, add the optional "OnMouseMove" browser code.
  3. Enter the following code lines in this code:
    IF EDT_UploadControl <> "" THEN
    IF IMG_ImageControl <> EDT_UploadControl THEN
    IMG_ImageControl = EDT_UploadControl
    END
    END
Note: This operation may not operate depending on the browser used and on the security level.
Note

Maximum size of files to upload

By default, the size of the files to upload is not limited in the WEBDEV engine. This size can be limited:
  • by the Web server used. See the documentation about the Web server used for more details.
  • by WEBDEV application server.
The file will not be uploaded if its size exceeds the limit size.
To modify the maximum size of the files to upload in the 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\23.0
    • On a 32-bit computer: HKEY_LOCAL_MACHINE\SOFTWARE\PC SOFT\WEBDEV\23.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.
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 required version
  • Version 9
Comments
Click [Add] to post a comment