download files to the device where the Wt application is running
Added by An GA over 10 years ago
I'm quite new in Wt and I would like to know if there is a possibility to upload a file from a remote pc to my web application, and then download this file in device where the application is running, for example to configure the device remotely with those uploaded files.
I've found some examples that apply WFileUpload, in order to upload the file to the web, but then, I would like to be able to download it to the device that is running the web application, and I found nothing about that. Is it possible to do it?
Thanks for your help in advance!
Replies (5)
RE: download files to the device where the Wt application is running - Added by Wim Dumon over 10 years ago
Not sure that I understand your question...
WFileUpload transfers a file from the PC where the browser runs to the device that runs the Wt application.
The question is: what do you want to do with the file once it is there?
BR,
Wim.
RE: download files to the device where the Wt application is running - Added by An GA over 10 years ago
Sorry for my bad explanations, I'm new in the web development environment and maybe I don't know the appropriate terminology.
The point is I would like to download some files in the device where the Wt web application is running. But those files will be on other PC, and I would like to have the possibility to move them from that PC to the device when I press one button in my web page for example.
Can somebody give me any clue to do that?
Thank you in advance!
AG
RE: download files to the device where the Wt application is running - Added by Стойчо Стефанов Stoycho Stefanov over 10 years ago
Hi An,
as Wim said you need the WFileUpload. Look at the widget gallery example http://www.webtoolkit.eu/widgets/forms/file-upload and the documentation too :)
WFileUpload transfers a file from the PC where the browser runs (i.e. the client) to the device that runs the Wt application (i.e., the server).
That means the client sends a file to the server (on a button click, see example) and on the server side you can do with this file whatever you want.
Best regards,
Stoycho
RE: download files to the device where the Wt application is running - Added by An GA over 10 years ago
Thank you for your answer, but still I don't get it :S
I have already seen that example, but after the client sends a file to the server I don't know how to download it. Do I have to download it using the URL link that I can get from an anchor to the loaded file and then apply some function that are available in some libraries such as libcurl, url or boost asio?
An example would be very helpful.
Best regards,
AG
RE: download files to the device where the Wt application is running - Added by Стойчо Стефанов Stoycho Stefanov over 10 years ago
Hi,
I don't know how to download it.
I really do know what does it mean.
When you upload a file to the server you can copy/move this file on the server (use Wt::WFileUpload::spoolFileName()) and you can than provide a link in your web application such that other users ( form different clients/sessions ) can download it to their machines (use WAnchor with a WLink to a WFileResource).
If your task is a file to travel on the route PC1 -> WtServer -> PC2 you could do this for example:
WFileUpload *Upload = new WFileUpload();
...
// on Upload->uploaded() do this:
WAnchor *Link = new WAnchor();
WFileResource *FileToDownload = new WFileResource(Upload.spoolFileName(),Link);
FileToDownload->suggestFileName(Upload.clientFileName());
Link->setLink(WLink(FileToDownload));
I hope this helps you!
Best regards,
Stoycho