Project

General

Profile

Wt::WFileDownload widget

Added by Richel Bilderbeek almost 13 years ago

I have used the Wt::WFileUpload to let a user select a file from his/her computer and upload it to a server. I wonder if there is a way to do this the other way around? I have already created a widget to select a file from a server (http://richelbilderbeek.nl/CppWtSelectFileDialog.htm), but I have no idea how to let the user download a file.

Thanks, Richel Bilderbeek


Replies (2)

RE: Wt::WFileDownload widget - Added by Wim Dumon almost 13 years ago

Richel,

To let a user download a file through http, you can use a WAnchor. But that only works for files that reside in the docroot of your http server.

To let a user download any file on your server, use a WFileResource (be sure to use suggestFileName() to set the name of the file, and you may want to set the content disposition type to attachment to suggest to the browser to use a 'save as' dialog). WFileResource + WAnchor = WFileDownload!

Wim.

RE: Wt::WFileDownload widget - Added by Richel Bilderbeek almost 13 years ago

Wim,

Thanks a lot!

I put it in my file download example (http://richelbilderbeek.nl/ToolTestSelectFileDialog.htm) and I enjoy it a lot already.

Best of wishes, Richel

    (1-2/2)