PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
This content has been translated automatically. Click here to view the French version.
  • Overview
  • Implementing file download in a WEBDEV site
  • Using the control description window (Button control, Link control, etc.)
  • Programming
  • Tip: forcing the file download (through programming only)
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
Overview
The download is the operation that consists in saving a file stored on the server onto the computer of Web user. The file is "downloaded" on the computer of Web user.
For example:
  • A DVD site allows you to download movie trailers onto your computer
  • Documents can be downloaded into an application for document management.
Implementing file download in a WEBDEV site
WEBDEV proposes several methods to perform a file download:
  • description window of the Button control or Link control used for the download.
  • programming in WLanguage.

Using the control description window (Button control, Link control, etc.)

To propose a download:
  1. Create a "Link" control, "Button" control, ...
  2. Open the control description window.
  3. In the "General" tab, select "Custom link (email,phone, etc.)".
  4. In "Address", select "File".
  5. Specify the full path of file (directory + name) found on the server. The file must be in the "_WEB" directory of the site.
At runtime, when this Link or Button control is clicked on:
  • if the file type is recognized, the file will be directly opened in the browser
  • if the file type is not recognized or if it corresponds to an executable, a dialog box allows you to download this file and/or to run it directly.

Programming

To propose file download through programming, simply use FileDisplay in the server click code of the Button or Link used to download the file.
The directory specified for the file must be a directory that can be accessed and written to (for example, the data directory (function fDataDir) or the resource directory (function fWebDir).
Example:
// Affiche le fichier dans le navigateur
// (si le format est connu sur le système, le fichier s'affiche directement)
FileDisplay(CompleteDir(fWebDir()) + "NOTES.TXT", "text/plain")
At runtime, when this Link or Button control is clicked on:
  • if the file type is recognized, the file will be directly opened in the browser.
  • if the file type is not recognized or if it corresponds to an executable, a dialog box allows you to download this file and/or to run it directly.

Tip: forcing the file download (through programming only)

To force the download regardless of the type of file, simply use the following line of code (in the server click code of the Button or Link control used to download the file):
FileDisplay(CompleteDir(fWebDir()) + "NOTES.TXT", "application/unknown")
However, the name of file proposed for download does not correspond to a valid name. To immediately propose the name of the file to download, simply add this name after the parameters of FileDisplay.
FileDisplay(CompleteDir(fWebDir()) + "NOTES.TXT", ...
"application/unknown", "Notes.TXT")
Minimum version required
  • Version 9
Comments
Click [Add] to post a comment