Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Download file ? how to..
#1
Hi All,

I'm a bit confused with the options available and hope someone will enlighten me and help me to understand how to accomplish the following:

My user has selected a number of rows in a table, and each row contains the name of an associated PDF file, saved in a public folder on the server. The user do have access to the folder, and can pick the files with file explorer or similar. And the user running the Webservice (http.sys) aslo have access to the folder.

I want to help the user getting the files of the public folder, into a folder on his workstation. What is the best way to I do that ?

Also a it will be more than one file to get, I want to avoid being asked any action for each file, and only be asked for a folder name for all the files at once. Is that possible ?

Thanks in advance for any help I can get

Regards
Soren
Reply
#2
Hi Soren, if you have a list of selected files, ZIP ou RAR this list and send to browser download.
Reply
#3
Hi Jose,

Thanks for your reply.

I take it you refer to webapplication.Sendfile when saying "send to browser download".

I'm trying to do it from inside my application, from the function where the user can search and select the rows in the table. is there a way to Zip or Rar the files from within the application ?

Regards
Soren
Reply
#4
Hi Jose,

Sorry for the previous reply. I know now what to do and have solved my problem / request.

Using TZipFile is the answer to putting files together in one zipfile.

WebApplication.Sendfile is indeed the answer to not only download the file, but also to have the application ask the user what to do with the file.

Just what I needed.

So solution is simple and in less than 10 lines of code, I have created a zipfile, added files to it, closed it, SendFile to activate a download the user can respond to, and freed it after. Only problem I had was, like when exporting gridlines to excel, to remember to release the lock set by the Button OnClick event I use to activate the zipping and sending, to have the application not waiting for Windows to finish (or whatever it is keeping the lock on my application).

If anybody want to see how I did it, just let med know and I'll post the source code. It's Delphi 10.3 and IW 15.1.12.

Regards
Soren
Reply
#5
Hi Soren. If is OnClick, put this code:
Code:
procedure TIWForm1.IWButton_ZipFilesClick(Sender: TObject);
begin
  ......
  AddToInitProc('ReleaseLock();');
end;
If is OnAsyncClick, put this code:
Code:
procedure TIWForm1.IWButton_ZipFilesAsyncClick(Sender: TObject);
begin
  ......
  WebApplication.CallBackResponse.AddJavaScriptToExecute('ReleaseLock();');
end;
Reply
#6
Hi Jose,

Thanks for your hints. It is OnClick I use, and I put it in the Scriptevents for the button, at design time.

Regards
Soren
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)